Another Linking error while porting.

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
-LC:/QNX630/target/qnx6/x86/lib -LC:/QNX630/target/qnx6/x86/usr/lib

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:

qcc –Vgcc_ntox86 –static –o mylib mylibfile1.o mylibfile2.o mylibfile3.o –lm

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’

Any Ideals?

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.