On Thu, Jan 22, 2004 at 09:43:31PM +1100, Ken Foskey wrote: > > I have grabbed an ini file parser from the net and the Makefile creates > libiniparser.a and I can compile and run the test program that compiles > and links with gcc. I have modified the headed to include extern "C" { > to the header file. When I link using the individual .o files it links > fine, but... > > g++ -c -g -Wall -I../include -I../iniparser/src afp2text.cpp > > g++ -c -g -Wall -I../include -I../iniparser/src codeconvert.cpp > > g++ -g -L../iniparser -liniparser afp2text.o codeconvert.o \ > -o afp2text > afp2text.o(.text+0x2c6): In function `main': > /data/program/afp2text/afp2text.cpp:151: undefined reference to > `iniparser_load' > collect2: ld returned 1 exit status > make: *** [afp2text] Error 1 > > Any suggestions... The (GNU) linker usually only links in object files from libraries if the object file provides some symbols which it has seen before. As a general rule, always list libraries as last options on the command line, in the order by which they depend on each other: g++ -g -L../iniparser afp2text.o codeconvert.o -liniparser > Problem # 2 > > (gdb) run > Starting program: /data/program/afp2text/afp2text > > Program received signal SIGSEGV, Segmentation fault. > 0x08048bbb in main (argc=1, argv=0xbffffbe4) at afp2text.cpp:99 > 99 char parm_filename[ 255 ] = "/apps/parms/afp/definition"; > (gdb) > > This is the very first line of the program. I even convert back to C > code, same result. Any suggestions on what to try would be appreciated. I suppose a simple hello world C++ program runs fine? Is this also related to the iniparser library? Can you supply a simple, runnable example which exhibits the error? Besides, I'd say without seeing any real code and a bit more information (command line arguments, GCC version, system information) it's quite hard to give advice here. -- Claudio Bley ASCII ribbon campaign (") Debian GNU/Linux user - against HTML email X http://www.cs.uni-magdeburg.de/~bley/ & vCards / \