提问人:yaodav 提问时间:11/6/2019 最后编辑:yaodav 更新时间:11/6/2019 访问量:95
.so 文件未找到构造函数
.so file the constructor not found
问:
我在我的计算机上创建了一个文件,它正在工作,
但是当我克隆代码并尝试使用命令再次创建时:.so
.so
cmake ..
sudo make install
它创建共享对象,但是当我尝试构建项目时,我得到:
无效 __gnu_cxx::new_allocator::构造, std::分配器 >&>(InventoryManager*, 标准::__cxx11::basic_string, std::分配器 >&)': /usr/local/include/c++/7.4.0/ext/new_allocator.h:136:未定义 参考 'InventoryManager::InventoryManager(std::__cxx11::basic_string, std::allocator >缺点
我该如何让它工作?
这是我的CMakeList.txt文件
cmake_minimum_required(VERSION 3.9)
project(InventoryManager VERSION 1.0.1 DESCRIPTION "InventoryManager v 1.0.1")
set(CMAKE_CXX_STANDARD 14)
include(GNUInstallDirs)
add_library(InventoryManager SHARED
src/InventoryItem.cpp
src/InventoryItemFactory.cpp
src/InventoryManager.cpp)
SET_TARGET_PROPERTIES(InventoryManager PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER include/InventoryItem.hpp
include/InventoryItemFactory.hpp
include/InventoryManager.hpp)
configure_file(InventoryManager.pc.in InventoryManager.pc @ONLY)
target_include_directories(InventoryManager PRIVATE .)
install(TARGETS InventoryManager
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_BINARY_DIR}/InventoryManager.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
编辑这是 InventoryManager.cpp 中的构造函数
#include <cmath>
#include <functional>
#include <include/InventoryManager.hpp>
#include <iostream>
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;
}
这是 .h 文件中的声明
#include <string>
#include <mutex>
#include <map>
#include <memory>
#include "InventoryItem.hpp"
#include "InventoryItemFactory.hpp"
class InventoryManager
{
public:
explicit InventoryManager(const std::string &symbol);
/* more functions */
}
答: 暂无答案
评论
InventoryManager.cpp