我从项目中删除了所有类,这样就留下了三个错误:
error_code.hpp:222: undefined reference to `boost::system::generic_category()
使用Netbeans IDE
点击文件 - >项目属性 - >链接
在Libraries旁边,添加了libboost_system.so
摆脱了对boost :: system :: generic_category()
的三个未定义的引用现在它给出了:
CLEAN SUCCESSFUL (total time: 123ms)
cd '/home/michaeleric/NetBeansProjects/NNW'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/michaeleric/NetBeansProjects/NNW'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/nnw
make[2]: Entering directory `/home/michaeleric/NetBeansProjects/NNW'
mkdir -p build/Debug/GNU-Linux/_ext/d028d44d
rm -f "build/Debug/GNU-Linux/_ext/d028d44d/CGrid.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/GNU-Linux/_ext/d028d44d/CGrid.o.d" -o build/Debug/GNU-Linux/_ext/d028d44d/CGrid.o ../../Desktop/NN_22_05_17/CGrid.cpp
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/nnw build/Debug/GNU-Linux/_ext/d028d44d/CGrid.o -L/usr/include/boost -lboost_system
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux/nnw] Error 1
make[2]: Leaving directory `/home/michaeleric/NetBeansProjects/NNW'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/michaeleric/NetBeansProjects/NNW'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 6s)
这个错误是什么意思以及如何修复?
休息所需的课程
#include </usr/include/boost/thread/thread.hpp>
#include </usr/include/boost/thread/xtime.hpp>
#include </usr/include/boost/iostreams/write.hpp>
#define byte unsigned char
#define Thread boost::thread
class CGrid
{
Thread* GetThread();
bool SetThread(Thread* thread);
};
答案 0 :(得分:0)
如果我用
编译它/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
我得到了相同的链接器错误
main
但是,如果我添加一个空的#define
函数,它编译得很好。 (我还用typedef
替换了你丑陋的#include </usr/include/boost/thread/thread.hpp>
#include </usr/include/boost/thread/xtime.hpp>
#include </usr/include/boost/iostreams/write.hpp>
typedef unsigned char byte;
typedef boost::thread Thread;
class CGrid
{
Thread* GetThread();
bool SetThread(Thread* thread);
};
int main() {}
替换。)
main
如果这是一个目标文件而-c
在另一个翻译单元中,请使用g++ -c test.cpp -lboost_system
参数进行编译:
class Foo(Base):
__tablename__ = 'foo'
can_be_deleted = Column(Boolean, default=False)
bar = Column(
GUID(), ForeignKey('bar.id', ondelete="CASCADE")
)