ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Header files are typically used for declaring functions, however, and again typically, the implementation for such functions is done within the library file.
You indicated that you are using a static library 'libnfiq.a' and 'libimage.a'. You should check each of these to ensure that the unreferenced functions are indeed present. For example:
Header files are typically used for declaring functions, however, and again typically, the implementation for such functions is done within the library file.
You indicated that you are using a static library 'libnfiq.a' and 'libimage.a'. You should check each of these to ensure that the unreferenced functions are indeed present. For example:
you have missed some -I <path/to/include/files> flags
Dear sir,
Can you please let me know briefly so that i can learn from this mistake where i am going wrong
my library are present at the /home/ivb/quality_separate so i used -L symbol to get to the directory and then used the -l to link respective library. and header files are included in C code Itself. If possble Can you please help regarding this
to compile something.c you need header files, you specify the location of headers by -I <path>. you will specify the name of the required headers in the source files by #include <filename> lines.
lo link several object files into an app you may need libraries, and you need to specify the location of those libs by -L <path>. you will specify the name of the required libs by -l <name-of-the-lib>
Code:
# so step one:
g++ -o quality.o -c quality.c -I <path1> -I<path2> ....
# this will create quality.o
# step two:
g++ -o quality quality.o -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
# this will create the app quality.
# all the above in one step:
g++ -o quality quality.c -I <path1> -I<path2> -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
you have some #includes in your source but the corresponding -I <path> is missing
(you need not use -I, -L and -l for default headers and libs)
to compile something.c you need header files, you specify the location of headers by -I <path>. you will specify the name of the required headers in the source files by #include <filename> lines.
lo link several object files into an app you may need libraries, and you need to specify the location of those libs by -L <path>. you will specify the name of the required libs by -l <name-of-the-lib>
Code:
# so step one:
g++ -o quality.o -c quality.c -I <path1> -I<path2> ....
# this will create quality.o
# step two:
g++ -o quality quality.o -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
# this will create the app quality.
# all the above in one step:
g++ -o quality quality.c -I <path1> -I<path2> -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
you have some #includes in your source but the corresponding -I <path> is missing
(you need not use -I, -L and -l for default headers and libs)
Dear sir,
Thanks for such clean reply i got your point. i think we might need to give the path of the Header files -I<Path> when we are not using the defualt header files
i tried your suggestions so my make file look like
Code:
all:
# so step one:
g++ -o quality.o -c quality.c -I /usr/include/nfiq -I usr/include/nfiq
# this will create quality.o
# step two:
g++ -o quality quality.o -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
# this will create the app quality.
# all the above in one step:
# g++ -o quality quality.c -I /usr/include/nfiq/ -I /usr/include/nfiq/ -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
clean:
rm -f quality.o quality
help:
@echo 'make would compile and create the library and create a link'
@echo 'make clean would remove the object file and executables'
but i am still getting the same results
Code:
$ make
# step one:
g++ -o quality.o -c quality.c -I /usr/include/nfiq -I /usr/include/nfiq
quality.c: In function ‘int main()’:
quality.c:40:20: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
# this will create quality.o
# step two:
g++ -o quality quality.o -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
quality.o: In function `main':
quality.c:(.text+0x6c): undefined reference to `read_and_decode_grayscale_image(char*, int*, unsigned char**, int*, int*, int*, int*, int*)'
quality.c:(.text+0xf8): undefined reference to `comp_nfiq(int*, float*, unsigned char*, int, int, int, int, int*)'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Regards
rohaan
Last edited by rohaanembedded; 09-13-2013 at 01:34 AM.
so first step works, you have got an error during the second step. It means you have a missing lib from that command.
do you have both libimage.so and libimage.a? Do you haev both libnfiq.so and libnfiq.a?
so first step works, you have got an error during the second step. It means you have a missing lib from that command.
do you have both libimage.so and libimage.a? Do you haev both libnfiq.so and libnfiq.a?
please compile with g++ -g .... (so add -g to both lines) and post the result.
also can you try gcc intead of g++ (that means gcc -o .....)
thanks
Sir if i use gcc instead of g++ it gives undefined reference to everything I think it doesnt link the library
results
Code:
$ make
# so step one:
gcc -o quality.o -c quality.c -I /usr/include/nfiq -I /usr/include/nfiq
# this will create quality.o
# step two:
gcc -o quality quality.o -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
/home/ivb/quality_separate/libnfiq.a(nfiq.o): In function `comp_nfiq_flex':
nfiq.c:(.text+0x3a4): undefined reference to `lfsparms_V2'
nfiq.c:(.text+0x460): undefined reference to `get_minutiae'
nfiq.c:(.text+0x4d4): undefined reference to `free_minutiae'
nfiq.c:(.text+0x5a0): undefined reference to `free_minutiae'
nfiq.c:(.text+0x644): undefined reference to `runmlp2'
nfiq.c:(.text+0x687): undefined reference to `free_minutiae'
/home/ivb/quality_separate/libnfiq.a(znorm.o): In function `comp_znorm_stats':
znorm.c:(.text+0x116): undefined reference to `ssx_stddev'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `ihead_decode_mem':
imgdecod.c:(.text+0x2c): undefined reference to `get_width'
imgdecod.c:(.text+0x38): undefined reference to `get_height'
imgdecod.c:(.text+0x44): undefined reference to `get_depth'
imgdecod.c:(.text+0x50): undefined reference to `get_density'
imgdecod.c:(.text+0x5c): undefined reference to `get_compression'
imgdecod.c:(.text+0x118): undefined reference to `get_complen'
imgdecod.c:(.text+0x1bc): undefined reference to `set_compression'
imgdecod.c:(.text+0x1cc): undefined reference to `set_complen'
imgdecod.c:(.text+0x220): undefined reference to `inv_bytes'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `.L26':
imgdecod.c:(.text+0x3a0): undefined reference to `png_decode_mem'
imgdecod.c:(.text+0x3e4): undefined reference to `get_IMG_DAT_image'
imgdecod.c:(.text+0x412): undefined reference to `free_IMG_DAT'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `.L25':
imgdecod.c:(.text+0x4d0): undefined reference to `openjpeg2k_decode_mem'
imgdecod.c:(.text+0x514): undefined reference to `get_IMG_DAT_image'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `.L23':
imgdecod.c:(.text+0x660): undefined reference to `jpegb_decode_mem'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `.L21':
imgdecod.c:(.text+0x708): undefined reference to `wsq_decode_mem'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `.L22':
imgdecod.c:(.text+0x7e0): undefined reference to `jpegl_decode_mem'
imgdecod.c:(.text+0x824): undefined reference to `get_IMG_DAT_image'
imgdecod.c:(.text+0x928): undefined reference to `free_IMG_DAT'
/home/ivb/quality_separate/libimage.a(imgdecod.o): In function `read_and_decode_grayscale_image':
imgdecod.c:(.text+0xdd2): undefined reference to `is_ANSI_NIST_file'
imgdecod.c:(.text+0xf27): undefined reference to `read_ANSI_NIST_file'
imgdecod.c:(.text+0xf97): undefined reference to `get_first_grayprint'
imgdecod.c:(.text+0xfb5): undefined reference to `free_ANSI_NIST'
imgdecod.c:(.text+0x1092): undefined reference to `free_ANSI_NIST'
imgdecod.c:(.text+0x10ec): undefined reference to `free_ANSI_NIST'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `.L2':
imgutil.c:(.text+0x34): undefined reference to `fatalerr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `SizeFromDepth':
imgutil.c:(.text+0x109): undefined reference to `ceil'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `init_image_data':
imgutil.c:(.text+0x1f6): undefined reference to `syserr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `WordAlignFromDepth':
imgutil.c:(.text+0x231): undefined reference to `ceil'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `allocate_image':
imgutil.c:(.text+0x320): undefined reference to `calloc_uchar'
imgutil.c:(.text+0x3aa): undefined reference to `fatalerr'
imgutil.c:(.text+0x402): undefined reference to `fatalerr'
imgutil.c:(.text+0x45a): undefined reference to `fatalerr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `mallocate_image':
imgutil.c:(.text+0x500): undefined reference to `malloc_uchar'
imgutil.c:(.text+0x58a): undefined reference to `fatalerr'
imgutil.c:(.text+0x5e2): undefined reference to `fatalerr'
imgutil.c:(.text+0x63a): undefined reference to `fatalerr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `alloc_short_image':
imgutil.c:(.text+0x6ba): undefined reference to `syserr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `alloc_char_image':
imgutil.c:(.text+0x73a): undefined reference to `syserr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `alloc_int_image':
imgutil.c:(.text+0x7aa): undefined reference to `syserr'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `width_16':
imgutil.c:(.text+0x7e9): undefined reference to `ceil'
/home/ivb/quality_separate/libimage.a(imgutil.o): In function `allocate_aligned_image':
imgutil.c:(.text+0x94e): undefined reference to `fatalerr'
imgutil.c:(.text+0x976): undefined reference to `fatalerr'
imgutil.c:(.text+0x9a6): undefined reference to `fatalerr'
imgutil.c:(.text+0x9d2): undefined reference to `syserr'
/home/ivb/quality_separate/libimage.a(imgtype.o): In function `jpeg_type':
imgtype.c:(.text+0x46): undefined reference to `getc_marker_jpegl'
imgtype.c:(.text+0x80): undefined reference to `getc_marker_jpegl'
imgtype.c:(.text+0xb8): undefined reference to `getc_skip_marker_segment'
imgtype.c:(.text+0xd8): undefined reference to `getc_marker_jpegl'
/home/ivb/quality_separate/libimage.a(imgtype.o): In function `image_type':
imgtype.c:(.text+0x220): undefined reference to `getc_ushort'
imgtype.c:(.text+0x32d): undefined reference to `png_sig_cmp'
imgtype.c:(.text+0x38c): undefined reference to `is_ANSI_NIST'
/home/ivb/quality_separate/libimage.a(intrlv.o): In function `compute_component_padding':
intrlv.c:(.text+0xaf): undefined reference to `ceil'
intrlv.c:(.text+0xfa): undefined reference to `ceil'
intrlv.c:(.text+0x147): undefined reference to `ceil'
intrlv.c:(.text+0x195): undefined reference to `ceil'
/home/ivb/quality_separate/libimage.a(intrlv.o): In function `intrlv2not_mem':
intrlv.c:(.text+0x2c2): undefined reference to `ceil'
/home/ivb/quality_separate/libimage.a(intrlv.o):intrlv.c:(.text+0x31f): more undefined references to `ceil' follow
/home/ivb/quality_separate/libimage.a(imageops.o): In function `WordAlignImage':
imageops.c:(.text+0xa3): undefined reference to `malloc_uchar'
/home/ivb/quality_separate/libimage.a(img_io.o): In function `read_raw_from_filesize':
img_io.c:(.text+0x26): undefined reference to `filesize'
/home/ivb/quality_separate/libimage.a(img_io.o): In function `write_raw_or_ihead':
img_io.c:(.text+0x791): undefined reference to `nullihdr'
img_io.c:(.text+0x7a1): undefined reference to `set_id'
img_io.c:(.text+0x7a9): undefined reference to `set_created'
img_io.c:(.text+0x7b9): undefined reference to `set_width'
img_io.c:(.text+0x7c9): undefined reference to `set_height'
img_io.c:(.text+0x7d5): undefined reference to `set_depth'
img_io.c:(.text+0x7e5): undefined reference to `set_density'
img_io.c:(.text+0x7f5): undefined reference to `set_align'
img_io.c:(.text+0x805): undefined reference to `set_compression'
img_io.c:(.text+0x815): undefined reference to `set_complen'
img_io.c:(.text+0x82a): undefined reference to `set_whitepix'
img_io.c:(.text+0x836): undefined reference to `writeihdr'
img_io.c:(.text+0x89c): undefined reference to `set_whitepix'
/home/ivb/quality_separate/libimage.a(readihdr.o): In function `ReadBinaryRaster':
readihdr.c:(.text+0x3a): undefined reference to `readihdr'
readihdr.c:(.text+0x4a): undefined reference to `get_depth'
readihdr.c:(.text+0x73): undefined reference to `fatalerr'
readihdr.c:(.text+0x7b): undefined reference to `get_width'
readihdr.c:(.text+0x86): undefined reference to `get_height'
readihdr.c:(.text+0x94): undefined reference to `get_density'
readihdr.c:(.text+0xa2): undefined reference to `get_compression'
readihdr.c:(.text+0xae): undefined reference to `get_complen'
readihdr.c:(.text+0xf1): undefined reference to `malloc_uchar'
readihdr.c:(.text+0x162): undefined reference to `malloc_uchar'
readihdr.c:(.text+0x1fc): undefined reference to `fatalerr'
readihdr.c:(.text+0x240): undefined reference to `set_compression'
readihdr.c:(.text+0x250): undefined reference to `set_complen'
readihdr.c:(.text+0x2cc): undefined reference to `syserr'
readihdr.c:(.text+0x2e8): undefined reference to `inv_bytes'
/home/ivb/quality_separate/libimage.a(readihdr.o): In function `ReadIheadRaster':
readihdr.c:(.text+0x390): undefined reference to `readihdr'
readihdr.c:(.text+0x3d0): undefined reference to `fatalerr'
readihdr.c:(.text+0x411): undefined reference to `fatalerr'
readihdr.c:(.text+0x44f): undefined reference to `fatalerr'
readihdr.c:(.text+0x490): undefined reference to `fatalerr'
readihdr.c:(.text+0x4d0): undefined reference to `fatalerr'
readihdr.c:(.text+0x51a): undefined reference to `malloc_uchar'
readihdr.c:(.text+0x58a): undefined reference to `fatalerr'
readihdr.c:(.text+0x5da): undefined reference to `malloc_uchar'
readihdr.c:(.text+0x78c): undefined reference to `syserr'
readihdr.c:(.text+0x7a8): undefined reference to `inv_bytes'
collect2: ld returned 1 exit status
make: *** [all] Error 1
and with g++ -g option i get same result
Code:
# step one:
g++ -g -o quality.o -c quality.c -I /usr/include/nfiq -I /usr/include/nfiq
quality.c: In function ‘int main()’:
quality.c:40:20: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
# this will create quality.o
# step two:
g++ -g -o quality quality.o -L /home/ivb/quality_separate -l nfiq -L /home/ivb/quality_separate -l image
quality.o: In function `main':
/home/ivb/quality_separate/quality.c:55: undefined reference to `read_and_decode_grayscale_image(char*, int*, unsigned char**, int*, int*, int*, int*, int*)'
/home/ivb/quality_separate/quality.c:64: undefined reference to `comp_nfiq(int*, float*, unsigned char*, int, int, int, int, int*)'
collect2: ld returned 1 exit status
make: *** [all] Error 1
-g is used to keep debug info. You can see the differences - without -g:
quality.c:(.text+0x6c): undefined reference to `read_and_decode_grayscale_image(char*, int*, unsigned char**, int*, int*, int*, int*, int*)
with -g:
/home/ivb/quality_separate/quality.c:55: undefined reference to `read_and_decode_grayscale_image(char*, int*, unsigned char**, int*, int*, int*, int*, int*)'
So the first step is ok again, in the second step you got another errors, the previous errors were not displayed. I think you need to add more libs with -l. What kind of libs do you have next to libimage?
(please try to use gcc -g ...)
-g is used to keep debug info. You can see the differences - without -g:
quality.c:(.text+0x6c): undefined reference to `read_and_decode_grayscale_image(char*, int*, unsigned char**, int*, int*, int*, int*, int*)
with -g:
/home/ivb/quality_separate/quality.c:55: undefined reference to `read_and_decode_grayscale_image(char*, int*, unsigned char**, int*, int*, int*, int*, int*)'
So the first step is ok again, in the second step you got another errors, the previous errors were not displayed. I think you need to add more libs with -l. What kind of libs do you have next to libimage?
(please try to use gcc -g ...)
Dear sir,
Ok i will there some more lib i dont think these are relevent but i will try and link and compile as i want to use it as app
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.