0
votes

I have a project in which I have Library Course/CommandParser/libcli.a Project Dir is : Course

When I am trying to create an executable by running the below command in 'Course' dir, it is giving me linking error.

g++ -g TcpClientDBManager.o TcpClientServiceManager.o TcpNewConnectionAcceptor.o TcpServerController.o network_utils.o TcpClient.o ByteCircularBuffer.o TcpMsgDemarcar.o TcpMsgFixedSizeDemarcar.o TcpMsgVariableSizeDemarcar.o testapp.o -o testapp.exe -lpthread -LCommandParser -lcli

/usr/bin/ld: testapp.o: in function `main':
/home/vm/src/TCPServerlib/Course/testapp.cpp:45: undefined reference to `init_libcli()'
/usr/bin/ld: /home/vm/src/TCPServerlib/Course/testapp.cpp:46: undefined reference to `start_shell()'
collect2: error: ld returned 1 exit status

The unreferenced functions belong to static library Course/CommandParser/libcli.a.

What wrong may I doing here that linking is failing ?

vm@ubuntu:~/src/TCPServerlib/Course$ ls CommandParser/libcli.a
CommandParser/libcli.a
And is the init_libcli function defined (implemented) in the library you link with? - Some programmer dude
yeah definitely. Both fns are implemented. Lib is working good with other projects, but this one is giving me problem in linking. - Abhishek Sagar
How do you build the library? In which object file (or files) do these functions defined? - Some programmer dude
Library has its own makefile which is called by main project's makefile. The fns are defined in src file of the library. Actually, any library fn is giving same error, so linker is not able to link it somehow. - Abhishek Sagar
And how does this unknown makefile build the library? To me it seems like the library isn't built correctly or with all object files needed. So please edit your question to show the makefile to us. Also, clean the library build (delete all objects files and the library itself) and rebuild it from scratch. Then include the full and complete build output of the library in your question. - Some programmer dude