I have a problem that I trying to solve for a long time. I have a library that I wrote using clion and I creating .so files using this answer and I'm linking it to my project, until today its work fine but afterI edit the library and rebuild it using
cmake .
sudo make install
the output of the cmake . command is:
-- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/yaodav/Desktop/git_repo/lib/internal/InventoryManager
and the sudo make output is:
-- Install configuration: "" -- Installing: /usr/local/lib64/libInventoryManager.so.1.0.1 -- Installing: /usr/local/lib64/libInventoryManager.so.1 -- Installing: /usr/local/lib64/libInventoryManager.so -- Installing: /usr/local/include/InventoryItem.hpp -- Installing: /usr/local/share/pkgconfig/InventoryManager.pc
but when I'm trying to build my program th build failed on:
CMakeFiles/test.dir/main.cpp.o: In function
void __gnu_cxx::new_allocator<InventoryManager>::construct<InventoryManager, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(InventoryManager*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': /usr/local/include/c++/7.4.0/ext/new_allocator.h:136: undefined reference to
InventoryManager::InventoryManager(std::__cxx11::basic_string, std::allocator > const&)'
this is the constructor:
InventoryManager::InventoryManager(const std::string &symbol):m_Symbol(symbol),m_itemFactory(*(new InventoryItemFactory(symbol)))
{
m_InventoryQty = 0;
m_InventoryItemValue = 0;
m_TotalInventoryValue = 0;
m_CurrentInventoryValue = 0;
}
this is the relevant (I think) lines from the project cmake file
include_directories(../lib/internal/InventoryManager/include)
link_directories(../lib/internal/InventoryManager)
add_executable(test ${SOURCE_FILES})
target_link_libraries(test InventoryManager)
Aucun commentaire:
Enregistrer un commentaire