c++ compiling problem
I'm trying to compile a c++ program, which is something I didn't do for a long time...
What I'm trying is:
g++ -c A.cpp -o A.o
g++ -c dir/B.h -o B.o
which seem to work, and then I try:
g++ A.o B.o -o A -lX11 -lpthread
and get:
Bo: file not recognized: File format not recognized
collect2: ld returned 1 exit status
What is the problem?
Thanks a lot :)
Omit the -o argument when you compile bh, and you will likely see that g++ creates a file named bhgch rather than bo That file is a "pre-compiled header file". By renaming in bo, you are lying to the subsequent invocation of g++ about the contents of the file. If bh is a header file, then you should include it in a.cpp. If bh contains function definitions, you should rename it b.cpp.
g++ -c dir/B.h -o B.o
Why are you compiling a header file?
I assume A.cpp includes dir/Bh - so you don't need a separate compiler invocation to compile the header.
You're compiling a header file. No good can come of that. :-)
链接地址: http://www.djcxy.com/p/15138.html上一篇: main()真的是C ++程序的开始吗?
下一篇: c ++编译问题