Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have a funny g++ "undefined reference" link error. I have one file which called frg_gsn_svc.cpp which implements a function: frg_gsn_start_svc(in_addr*, in_addr*, in_addr*, unsigned char, unsigned char, int*, fd_set*, ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    7

    funny g++ "undefined reference" link error

    Hi,

    I have a funny g++ "undefined reference" link error.

    I have one file which called frg_gsn_svc.cpp which implements a function:

    frg_gsn_start_svc(in_addr*, in_addr*, in_addr*, unsigned char, unsigned char, int*, fd_set*, gengetopt_args_info*, pthread_mutex_t*, pthread_mutex_t*)

    In the same directory I have another file frg_sgsn.cpp which calls this function in main(). Both files compiles fine generates .o files.

    I don't understand why I got the following error:

    g++ -Wall -O -g -c -I../include -I../../common/include -I../../gtp/include -I../../pdp/include -I../../mf/include -I../../thirdparty/lnx/include frg_gsn_svc.cpp frg_sgsn.cpp

    g++ -Wall -O -g frg_gsn_svc.o frg_sgsn.o ../../pdp/lib/libfrgpdp.a ../../gtp/lib/libfrggtp.a ../../common/lib/libfrggen.a ../../mf/lib/libfrgmf.a ../../thirdparty/lnx/lib/liblinx.a /usr/lib/librt.so -o ../bin/frg-sgsn -pthread -lpcap
    frg_sgsn.o: In function `main':

    frg_sgsn.cpp:215: undefined reference to `frg_gsn_start_svc(in_addr*, in_addr*, in_addr*, unsigned char, unsigned char, int*, fd_set*, gengetopt_args_info*, pthread_mutex_t*, pthread_mutex_t*)'
    collect2: ld returned 1 exit status

    funny thing is that it used to complie and link fine, only after I made some changes to other directories where generates library libfrgpdp.a (the library is complied and gnerated fine)

    But this link error happens.

    I am compile on a Ubuntu machine, anybody please help out.

    Thanks,

    Yuyong

  2. #2
    Just Joined!
    Join Date
    Oct 2009
    Posts
    7
    Never mind, I changed the argument list in the source file, that is why it has the link error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...