I am currently trying to port code from qnx4.25 to qnx6 and I currently have run across a problem with getting a library file to build correctly. One of the object files Iâ€™m using to build my library uses math function such as â€œsqrt, acos and sinâ€
Find out where the libraries are located and provide â€“L option, such as
Try to move -lm to the end of the command.
Moving the -lm to the end do the trick.
I just recently started seeing another problem with the same command and the â€“lm moved to the end:
I now get a linker error that calls out /usr/qnx632/target/qnx6/x86/lib/crt1.o that looks something like this
/usr/qnx632/target/qnx6/x86/lib/crt1.o(.text+0x4): undefined reference to â€˜mainâ€™
/usr/qnx632/target/qnx6/x86/lib/crt1.o: In Function â€˜_startâ€™:
/usr/qnx632/target/qnx6/x86/lib/crt1.o(.text+0x54): undefined reference to â€˜mainâ€™
The output is called mylib are you trying to build an executable or a library. Sounds like it’s a library because it can’t find main(). For library you need to add -A to indicate you want to generate a library and not an executable.
At what point in the syntex should the -A be placed?
I’ve replaced the -o with the -A and it executes with no errors. Thanks
Ok. I have my new library now, but event though it was linked using the -static parameter, I have to use -shared parameter to compile and link my programs with this new library. Why is this?
Probably because you didn’t read the documentation.