Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Linker options for qcc: QNX Build Errors: (6 Items)
   
Linker options for qcc: QNX Build Errors  
Hi, In QNX build, am seeing shared objects are generated instead of binary executable. While invoking qcc the option "-
shared" is not passed but "-fPIC" is passed. Any one please give me a clue what will trigger qcc to generate shared 
object other than "-fPIC" option.
Re: Linker options for qcc: QNX Build Errors  
Hi,

I've also seen this issue when using the -fPIC option to generate an executable. The resulting binary becomes a shared 
object instead of an executable. This only occurs when I use QCC (SDP 6.6.0) instead of the arm-unknown-nto-qnx6.6.0eabi
-g++.
For information, I use cmake to build my program and I add "-fPIC" to both CMAKE_C_FLAGS and CMAKE_CXX_FLAGS.

To verify the output, I use the "file" command which shows
testapp.helloworld: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), 
BuildID[md5/uuid]=0x2bd07205a3e7f54e1ea9a2cb7e496598, not stripped

Is there a patch or a way to workaround it?

Thanks,
Anton
Re: Linker options for qcc: QNX Build Errors  
On 14-09-19 05:20 PM, Anton Indrawan wrote:
> Hi,
>
> I've also seen this issue when using the -fPIC option to generate an executable. The resulting binary becomes a shared
 object instead of an executable. This only occurs when I use QCC (SDP 6.6.0) instead of the arm-unknown-nto-qnx6.6.
0eabi-g++.
> For information, I use cmake to build my program and I add "-fPIC" to both CMAKE_C_FLAGS and CMAKE_CXX_FLAGS.
>
> To verify the output, I use the "file" command which shows
> testapp.helloworld: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), 
BuildID[md5/uuid]=0x2bd07205a3e7f54e1ea9a2cb7e496598, not stripped
>
> Is there a patch or a way to workaround it?

Are you using the official SDP QNX 6.6.0 toolchain? Because that's not 
the behaviour I see with it

$ arm-unknown-nto-qnx6.6.0-g++ --version
arm-unknown-nto-qnx6.6.0-g++ (GCC) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ arm-unknown-nto-qnx6.6.0-g++ -fPIC hw.cc
$ file a.out
a.out: ELF 32-bit LSB  executable, ARM, version 1, dynamically linked 
(uses shared libs), BuildID[md5/uuid]=6b2033ca61dadd8e43d2ac1d6ca71752, 
not stripped

Regards,

Ryan Mansfield



Re: Linker options for qcc: QNX Build Errors  
Hi Ryan,

Yes, I am using the official QNX SDP 6.6.0 toolchain.

Please use QCC to reproduce it.
I think I've tried both with "QCC -Vgcc_ntoarmv7le" which links against to libcpp.so and "QCC Vgcc_ntoarmv7le -Y_gpp" 
which links against libstdc++.so.
Both options resulted in a shared library instead of an executable.

Please let me know if you can(not) reproduce it.

Thank you,
Anton



Re: Linker options for qcc: QNX Build Errors  
On 14-09-21 04:37 PM, Anton Indrawan wrote:
> Hi Ryan,
>
> Yes, I am using the official QNX SDP 6.6.0 toolchain.
>
> Please use QCC to reproduce it.
> I think I've tried both with "QCC -Vgcc_ntoarmv7le" which links against to libcpp.so and "QCC Vgcc_ntoarmv7le -Y_gpp" 
which links against libstdc++.so.
> Both options resulted in a shared library instead of an executable.

Sorry, yes I can. I misread your post. I thought you said it was only 
happening with gcc drivers which was unexpected.

-fpic has been an alias to -shared in qcc for quite awhile (well before 
6.6). One way around this behaviour is not to pass -fpic/-fPIC when 
linking, or to just pass it directly to the compiler.

# qcc t.c -fpic -c
# qcc t.o
# file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 
dynamically linked (uses shared libs), 0 bytes lazy stack, 4096 bytes 
preallocated stack, not stripped

or

# qcc t.c -Wc,-fpic
# file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 
dynamically linked (uses shared libs), 0 bytes lazy stack, 4096 bytes 
preallocated stack, not stripped

Regards,

Ryan Mansfield



Re: Linker options for qcc: QNX Build Errors  
Hi Ryan,

Your solution to use -Wc,-fPIC works well! I prefer this one-step solution instead of the other solution. because I am 
using the cmake build system where I can add the "-Wc,-fPIC" to the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS.

Thank you!

Best regards,
Anton