Discussion:
Help compiling g++ and C library + runtime crash
Ken Foskey
2004-01-22 10:43:31 UTC
Permalink
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...
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.
--
Thanks
KenF
OpenOffice.org developer
Claudio Bley
2004-01-22 18:13:56 UTC
Permalink
Post by Ken Foskey
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
/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
Post by Ken Foskey
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 / \
Ken Foskey
2004-01-22 21:26:53 UTC
Permalink
Post by Claudio Bley
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
So easy... Must have always done this by default previously.
Post by Claudio Bley
g++ -g -L../iniparser afp2text.o codeconvert.o -liniparser
Post by Ken Foskey
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.
Found it, the definition of one of the automatic was too large. It
crashed on startup. Reducing the size made it work. What is the limit?
gcc 3.3.3 from Debian Unstable.
--
Thanks
KenF
OpenOffice.org developer
l***@micron.com
2004-01-22 21:31:35 UTC
Permalink
The limit is OS or shell and not compiler dependent (as I understand it) and depends on what your stack size limit is. The default is often 8MB. You can view you current limit using the 'ulimit -s' command. It shows the limit in KB. You can set it to unlimited (or some other reasonable value) with the same command:
ulimit -s unlimited
or
ulimit -s 16384
to increase it to 16MB.
Cheers,
Lyle
-----Original Message-----
From: gcc-help-***@gcc.gnu.org [mailto:gcc-help-***@gcc.gnu.org]On
Behalf Of Ken Foskey
Sent: Thursday, January 22, 2004 2:27 PM
To: gcc-***@gcc.gnu.org
Subject: Re: Help compiling g++ and C library + runtime crash
Post by Claudio Bley
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.
Found it, the definition of one of the automatic was too large. It
crashed on startup. Reducing the size made it work. What is the limit?
gcc 3.3.3 from Debian Unstable.
3 Replies
6 Views
Permalink to this page
Disable enhanced parsing
Thread Navigation
Ken Foskey2004-01-22 10:43:31 UTC