Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Linking Errors: (8 Items)
   
Linking Errors  
This is my first posting on this forum and I'm newbie to QNX development. I'm developing drivers and application for QNX
 6.4.1 target system and using QNX6.5 IDE.
I'm able to complie, link and run a simple program on the target.  I can compile my code to get the object files IP330.o
,IP480.o, IPTest.o,   apc8620.o but I'm getting linking problem during building the project. 

common.mk :

# This is an automatically generated record.
# The area between QNX Internal Start and QNX Internal End is controlled by
# the QNX IDE properties.

ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)

#===== USEFILE - the file containing the usage message for the application. 
USEFILE=

# Next lines are for C++ projects only

EXTRA_SUFFIXES+=cxx cpp

#===== LDFLAGS - add the flags to the linker command line.
LDFLAGS+=-lang-c++ -l

VFLAG_g=-gstabs+

#===== EXTRA_LIBVPATH - a space-separated list of directories to search for library files.
EXTRA_LIBVPATH+=$(PROJECT_ROOT_apc8620_lib)/$(CPU)/$(patsubst o%,a%,$(notdir $(CURDIR)))  \
	$(PROJECT_ROOT_apc8620_lib)/$(CPU)/$(patsubst o%,so%,$(notdir $(CURDIR)))

#===== CCFLAGS - add the flags to the C compiler command line. 
CCFLAGS+=-w

include $(MKFILES_ROOT)/qmacros.mk


ifndef QNX_INTERNAL
QNX_INTERNAL=$(PROJECT_ROOT)/.qnx_internal.mk
endif
include $(QNX_INTERNAL)

include $(MKFILES_ROOT)/qtargets.mk

OPTIMIZE_TYPE_g=none
OPTIMIZE_TYPE=$(OPTIMIZE_TYPE_$(filter g, $(VARIANTS)))


Console Output:

/opt/qnx650/host/linux/x86/usr/bin/make -k CPULIST=x86 all --file=/tmp/QMakefile132138304544122139.tmp 
/opt/qnx650/host/linux/x86/usr/bin/make -j 1 -Cx86 -fMakefile all
make[1]: Entering directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86'
/opt/qnx650/host/linux/x86/usr/bin/make -j 1 -Co -fMakefile all 
make[2]: Entering directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o'
/bin/rm -f  /usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o/courier
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86  -lang-c++ -l    -o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace
/courier/x86/o/courier    IP330.o    IP480.o    IPTest.o    apc8620.o   -L . -L /x86/a -L /x86/so -L /opt/qnx650/target/
qnx6/x86/lib -L /opt/qnx650/target/qnx6/x86/usr/lib  -Wl,--rpath-link . -Wl,--rpath-link /x86/a -Wl,--rpath-link /x86/so
 -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/lib -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/usr/lib      
make[2]: Leaving directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o'
/opt/qnx650/host/linux/x86/usr/bin/make -j 1 -Co-g -fMakefile all
make[2]: Entering directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o-g'
/bin/rm -f  /usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o-g/courier_g
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86  -lang-c++ -l    -o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace
/courier/x86/o-g/courier_g    IP330.o    IP480.o    IPTest.o    apc8620.o   -L . -L /x86/a-g -L /x86/so-g -L /opt/qnx650
/target/qnx6/x86/lib -L /opt/qnx650/target/qnx6/x86/usr/lib  -Wl,--rpath-link . -Wl,--rpath-link /x86/a-g -Wl,--rpath-
link /x86/so-g -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/lib -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/usr/lib    
-g     
/opt/qnx650/host/linux/x86/usr/bin/ntox86-ld: cannot find -l-o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/
x86/o/courier
cc: /opt/qnx650/host/linux/x86/usr/bin/ntox86-ld error 1
make[2]: *** [/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o/courier] Error 1
make[2]: Target `all' not remade because of errors.
make[1]: [all] Error 2 (ignored)
/opt/qnx650/host/linux/x86/usr/bin/ntox86-ld: cannot find -l-o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/
x86/o-g/courier_g
cc: /opt/qnx650/host/linux/x86/usr/bin/ntox86-ld error 1
make[2]: *** [/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o-g/courier_g] Error 1
make[2]:...
View Full Message
Re: Linking Errors  
On 11-11-15 03:10 PM, sudhir katta wrote:
> This is my first posting on this forum and I'm newbie to QNX development. I'm developing drivers and application for 
QNX 6.4.1 target system and using QNX6.5 IDE.
> I'm able to complie, link and run a simple program on the target.  I can compile my code to get the object files IP330
.o,IP480.o, IPTest.o,   apc8620.o but I'm getting linking problem during building the project.

> #===== LDFLAGS - add the flags to the linker command line.
> LDFLAGS+=-lang-c++ -l


-l takes an arg, and since there's no arg, the final link is being 
parsed as -l 
"-o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o/courier"

Remove the -l or add whatever the missing library name is.

Regards,

Ryan Mansfield




Re: Linking Errors  
Rayan, Thank you very much for quick reply.  
I have removed -l but still I have linking errors. Here is my console output. 

apc8620.h has all the references and it is included in IP330.c. I think IP330.o  is not able to find references to `
apc8620_write_8' that are in apc8620.h.


/opt/qnx650/host/linux/x86/usr/bin/make -k CPULIST=x86 all --file=/tmp/QMakefile132138946534222147.tmp 
/opt/qnx650/host/linux/x86/usr/bin/make -j 1 -Cx86 -fMakefile all
make[1]: Entering directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86'
/opt/qnx650/host/linux/x86/usr/bin/make -j 1 -Co -fMakefile all 
make[2]: Entering directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o'
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall  -O -w          -DNDEBUG   -I. -I/usr0/home/skatta/
QNX_Workspace/ide-4.7-workspace/courier/x86/o -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86 -I/usr0/
home/skatta/QNX_Workspace/ide-4.7-workspace/courier -I/opt/qnx650/target/qnx6/usr/include     -DBUILDENV_qss  /usr0/home
/skatta/QNX_Workspace/ide-4.7-workspace/courier/IP330.c 
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall  -O -w          -DNDEBUG   -I. -I/usr0/home/skatta/
QNX_Workspace/ide-4.7-workspace/courier/x86/o -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86 -I/usr0/
home/skatta/QNX_Workspace/ide-4.7-workspace/courier -I/opt/qnx650/target/qnx6/usr/include     -DBUILDENV_qss  /usr0/home
/skatta/QNX_Workspace/ide-4.7-workspace/courier/IP480.c 
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall  -O -w          -DNDEBUG   -I. -I/usr0/home/skatta/
QNX_Workspace/ide-4.7-workspace/courier/x86/o -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86 -I/usr0/
home/skatta/QNX_Workspace/ide-4.7-workspace/courier -I/opt/qnx650/target/qnx6/usr/include     -DBUILDENV_qss  /usr0/home
/skatta/QNX_Workspace/ide-4.7-workspace/courier/IPTest.c 
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall  -O -w          -DNDEBUG   -I. -I/usr0/home/skatta/
QNX_Workspace/ide-4.7-workspace/courier/x86/o -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86 -I/usr0/
home/skatta/QNX_Workspace/ide-4.7-workspace/courier -I/opt/qnx650/target/qnx6/usr/include     -DBUILDENV_qss  /usr0/home
/skatta/QNX_Workspace/ide-4.7-workspace/courier/apc8620.c 
/bin/rm -f  /usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o/courier
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86  -lang-c++    -o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/
courier/x86/o/courier    IP330.o    IP480.o    IPTest.o    apc8620.o   -L . -L /x86/a -L /x86/so -L /opt/qnx650/target/
qnx6/x86/lib -L /opt/qnx650/target/qnx6/x86/usr/lib  -Wl,--rpath-link . -Wl,--rpath-link /x86/a -Wl,--rpath-link /x86/so
 -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/lib -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/usr/lib      
make[2]: Leaving directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o'
/opt/qnx650/host/linux/x86/usr/bin/make -j 1 -Co-g -fMakefile all
make[2]: Entering directory `/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o-g'
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall   -w             -I. -I/usr0/home/skatta/QNX_Workspace/
ide-4.7-workspace/courier/x86/o -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o-g -I/usr0/home/skatta/
QNX_Workspace/ide-4.7-workspace/courier/x86 -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier -I/opt/qnx650/
target/qnx6/usr/include    -g    -DVARIANT_g -DBUILDENV_qss  /usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/
IP330.c 
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall   -w             -I. -I/usr0/home/skatta/QNX_Workspace/
ide-4.7-workspace/courier/x86/o -I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/x86/o-g -I/usr0/home/skatta/
QNX_Workspace/ide-4.7-workspace/courier/x86...
View Full Message
Re: Linking Errors  
On 11-11-15 03:56 PM, sudhir katta wrote:
> Rayan, Thank you very much for quick reply.
> I have removed -l but still I have linking errors. Here is my console output.
>
> apc8620.h has all the references and it is included in IP330.c. I think IP330.o  is not able to find references to `
apc8620_write_8' that are in apc8620.h.

> /usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/IP330.c:98: undefined reference to `apc8620_write_8'
> /usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/IP330.c:99: undefined reference to `apc8620_write_8'

The problem is that you're not linking in the library that provides 
these definitions. Normally headers provide declarations but not 
definitions so including the header is insufficient. I can't tell you 
the library name that contains these symbols because they're don't come 
from system libraries. When you find the library, you link it in with 
-l<library name>. e.g. -lapc8620 or something.

Regards,

Ryan Mansfield
Re: Linking Errors  
Ryan,

1) I don't have external libraries. I have all the source code for the definition and it compiles to object files.  I 
have screenshot of my projects for your reference. 

2) I tried to include "-I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/" but it didn't work.
/opt/qnx650/host/linux/x86/usr/bin/qcc -Vgcc_ntox86  -lang-c++ -o/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/
courier/x86/o-g/courier_g apc8620.o IP330.o IP480.o IPTest.o  -L . -L /x86/a-g -L /x86/so-g -L /opt/qnx650/target/qnx6/
x86/lib -L /opt/qnx650/target/qnx6/x86/usr/lib  -Wl,--rpath-link . -Wl,--rpath-link /x86/a-g -Wl,--rpath-link /x86/so-g 
-Wl,--rpath-link /opt/qnx650/target/qnx6/x86/lib -Wl,--rpath-link /opt/qnx650/target/qnx6/x86/usr/lib, -I/usr0/home/
skatta/QNX_Workspace/ide-4.7-workspace/courier/ -wl, -g

3) I could not find this in documentation. What does --rpath-link does?

4) without IP modules apc8620 project builds and works fine. In courier project I have add new modules that uses apc8620
 functions.  IPTest calls IP330 and IP480. These IP modules call the apc8620 functions to write and read to memory.

Thanks,
Sudhir
Attachment: Text QNX 260.74 KB
Re: Linking Errors  
The file is QNX.png
Re: Linking Errors  
On 11-11-16 12:38 PM, sudhir katta wrote:
> Ryan,
>
> 1) I don't have external libraries. I have all the source code for the definition and it compiles to object files.  I 
have screenshot of my projects for your reference.

Which object file these symbols then? Do an ntox86-nm on whatever object 
you think provides them and make sure they're global symbols.

> 2) I tried to include "-I/usr0/home/skatta/QNX_Workspace/ide-4.7-workspace/courier/" but it didn't work.

-I is a compiler option to add to the compilers include search path so 
add it when you're linking doesn't make sense.

> 3) I could not find this in documentation. What does --rpath-link does?

It set link time shared library search path but if you have all of your 
symbols in objects then you shouldn't have to concern yourself with this 
option.

> 4) without IP modules apc8620 project builds and works fine. In courier project I have add new modules that uses 
apc8620 functions.  IPTest calls IP330 and IP480. These IP modules call the apc8620 functions to write and read to 
memory.

OK, again, if you're making use of these apc8620 functions, then you 
either need to link them into your 'courier' project as object files, or 
linking against a library that has them.

No one knwos where your symbols are defined except for you so you need 
to find out where they are and link the code in. If you can tell us 
where they come from, we can help you construct the appropriate way of 
linking them in.

Regards,

Ryan Mansfield
Re: Linking Errors  
Ryan,

Solved this error. The problem was that the apc8620.h has 

extern function(int i, float j) 
{ <implementation>} 

so it was being complied as declaration without definition. I have moved the function definition to apc8620.c and it 
complies without errors.

This link explains it all.
http://en.wikipedia.org/wiki/External_variable#Definition.2C_declaration_and_the_extern_keyword

I appreciate your help and time.

Regards,
Sudhir