0
gcc -c -o app main.o build/service.o -std=c++11 -lstdc++ -lboost_system -lboost_thread -lpthread simulation_tool.a 
gcc: warning: main.o: linker input file unused because linking not done
gcc: warning: build/service.o: linker input file unused because linking not done
gcc: warning: simulation_tool.a: linker input file unused because linking not done

gcc -o app main.o build/service.o -std=c++11 -lstdc++ -lboost_system -lboost_thread -lpthread simulation_tool.a 
build/service.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status

When I am giving -c option I am getting linking warnings as -c will not able to link, but without -c option I am not able to generate binary output whats wrong with compilation option?

I am trying to link .a file and with object file and generating binary as output in above compilation

  • Where to start? 1/ compile C++ with `g++`, not `gcc`. 2/ `g++ -c` expect source files , not object files. 3/ `build/service.o` is it really an object file or did you just rename it to end in `.o`? What does `file build/service.o` says? – YSC Dec 06 '17 at 13:00
  • `gcc -c` means "compile, but don't link". That's of course confusing when there is nothing to compile. :-) In the second case the problem seems to be with `service.o`. Perhaps it is damaged? Also, when linking C++ it is generally better to use `g++` rather than `gcc` (which is mainly for C). – Bo Persson Dec 06 '17 at 13:03
  • yes its object file only I have not renamed it @Y – user8913999 Dec 06 '17 at 13:04
  • When I am trying to generate complete project gcc -o simulation_application ../../main.cpp service.cpp -I ../server/ -I ../include/ -std=c++11 -lstdc++ -lboost_system -lboost_thread -lpthread It is generating proper binary file from above code @YSC – user8913999 Dec 06 '17 at 13:06

0 Answers0