Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
04-08-2003, 03:04 PM
|
#1
|
LQ Newbie
Registered: Apr 2003
Posts: 4
Rep:
|
g++ static build problem
I am trying to build a program statically. I compiled all of the source files similar to the following:
g++ -static -I/usr/include/gtkmm-2.0 -I/usr/lib/gtkmm-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/sigc++-1.2/include -I/usr/include/sigc++-1.2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/atk-1.0 -c CharFil.cc
Then I linked everything as follows:
c++ -static -g -O2 -I/usr/include/gtkmm-2.0 -I/usr/lib/gtkmm-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/sigc++-1.2/include -I/usr/include/sigc++-1.2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/atk-1.0 -o CharFil CharFil.o OutNameDlg.o OverwriteDlg.o WarningDlg.o DoneDlg.o SplashDlg.o AboutDlg.o HelpDlg.o InputFileSelection.o CFilter.o AsciiDlg.o dirbrowser.o -Wl,--export-dynamic /usr/lib/libgtkmm-2.0.so /usr/lib/libgdkmm-2.0.so /usr/lib/libatkmm-1.0.so /usr/lib/libgtk-x11-2.0.so /usr/lib/libpangomm-1.0.so /usr/lib/libglibmm-2.0.so /usr/lib/libsigc-1.2.so /usr/lib/libgdk-x11-2.0.so /usr/lib/libatk-1.0.so /usr/lib/libgdk_pixbuf-2.0.so -lm /usr/lib/libpangoxft-1.0.so /usr/lib/libpangox-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libgobject-2.0.so /usr/lib/libgmodule-2.0.so -ldl /usr/lib/libglib-2.0.so
Everything compiled and linked without errors. The executable CharFil was created, but when I try to run CharFil I receive the following message:
./CharFil: No such file or directory
I have tried to build the project statically several other ways, without success. The above was my first attempt.
Any help would be appreciated,
Joe-E
|
|
|
04-12-2003, 07:07 PM
|
#2
|
LQ Newbie
Registered: Apr 2003
Location: NY, USA
Posts: 16
Rep:
|
i know im pretty new to linux so if anything i say is wrong someone please correct me, but i think you have to change the file permission on CharFil so that you have execute permission. If you dont have permission i think that is the error message you will get.
stamour547
|
|
|
04-14-2003, 08:10 AM
|
#3
|
LQ Newbie
Registered: Apr 2003
Posts: 4
Original Poster
Rep:
|
I checked the permissions and the binary was already execuatble. So unfortunatly that doesn't seem to be the problem, but thank you for your advice stamour547.
Here's another attempt I made at statically linking:
c++ -o CharFil CharFil.o OutNameDlg.o OverwriteDlg.o WarningDlg.o DoneDlg.o SplashDlg.o AboutDlg.o HelpDlg.o InputFileSelection.o CFilter.o AsciiDlg.o dirbrowser.o -L/usr/X11R6/lib -Wl,-Bstatic -lgtkmm-2.0 -lgdkmm-2.0 -latkmm-1.0 -lgtk-x11-2.0 -lpangomm-1.0 -lglibmm-2.0 -lsigc-1.2 -latk-1.0 -lm -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lpangox-1.0 -lpangoxft-1.0 -lgdk_pixbuf-2.0 -lgdk-x11-2.0
Which throws the following errors:
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgtk-x11-2.0.a(gtkplug.o)(.text+0x10c2): In function `send_xembed_message':
: undefined reference to `XSendEvent'
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgtk-x11-2.0.a(gtkplug.o)(.text+0x121e): In function `xembed_set_info':
: undefined reference to `XChangeProperty'
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgtk-x11-2.0.a(gtksocket.o)(.text+0x4ff): In function `gtk_socket_realize':
: undefined reference to `XGetWindowAttributes'
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgtk-x11-2.0.a(gtksocket.o)(.text+0x52a): In function `gtk_socket_realize':
: undefined reference to `XSelectInput'
.......etc............etc..............etc.................etc............etc...............
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgdk-x11-2.0.a(gdkinput-xfree.o)(.text+0x1a5): In function `gdk_input_check_proximity':
: undefined reference to `XFreeDeviceState'
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgdk-x11-2.0.a(gdkinput-xfree.o)(.text+0x539): In function `_gdk_input_grab_pointer':
: undefined reference to `XGrabDevice'
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgdk-x11-2.0.a(gdkinput-xfree.o)(.text+0x585): In function `_gdk_input_grab_pointer':
: undefined reference to `XUngrabDevice'
/usr/lib/gcc-lib/i386-linux/3.2.3/../../../libgdk-x11-2.0.a(gdkinput-xfree.o)(.text+0x613): In function `_gdk_input_ungrab_pointer':
: undefined reference to `XUngrabDevice'
collect2: ld returned 1 exit status
If I link the following libraries dynamically, everything works fine: -lgdk_pixbuf-2.0 and -lgdk-x11-2.0. But this is not a static binary:
CharFil: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped
It has the following dependancies:
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x4001f000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x40031000)
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40094000)
libm.so.6 => /lib/libm.so.6 (0x4013d000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4015e000)
libc.so.6 => /lib/libc.so.6 (0x40166000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40276000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x40332000)
libdl.so.2 => /lib/libdl.so.2 (0x40336000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x40339000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x40368000)
libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x403ca000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x403d2000)
libXft.so.2 => /usr/X11R6/lib/libXft.so.2 (0x403e0000)
libz.so.1 => /lib/libz.so.1 (0x403f0000)
libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x403fd000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x40402000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x40426000)
libpangoxft-1.0.so.0 => /usr/lib/libpangoxft-1.0.so.0 (0x40475000)
libpangox-1.0.so.0 => /usr/lib/libpangox-1.0.so.0 (0x40494000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x404a0000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x404cf000)
Are my static libraries different from their shared library equivalents?
Thank you in advance for any help anyone can give me,
Joe-E
|
|
|
04-14-2003, 03:17 PM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
I might be on the completely wrong track here,
but I believe that you were using the dynamic
libraries in your first example, too :}
The names of the static libraries all end in .a,
not .so.
Cheers,
Tink
|
|
|
04-15-2003, 12:25 PM
|
#5
|
LQ Newbie
Registered: Apr 2003
Posts: 4
Original Poster
Rep:
|
Yes, I was hoping the -static flag used in the first example would link the shared libraries and their dependancies statically (if that can be done). What confused me was that I recieved no errors while compiling or linking. The binary executable was created, but when I attempted to run it the binary executable was not found.
In the second example the -static flag is used again, and the required libraries are included without the explicit instructions on whether to use their shared or static elements. I think in this case the -static flag instructs the linker to use all of the corresponding .a library files. However when I do this I recieve a large number of undefined reference errors. It's almost as if the .a library files do not include everything their .so equivalents do.
Hope someone can help,
Joe-E
|
|
|
04-15-2003, 02:37 PM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
I'm really starting to guess here,
I've never dieved into static linkage
with a TON of interdependent packages...
Maybe you'll have to recompile
gdk_pixbuf-2.0 and gdk-x11-2.0 for
static linkage, too?
Cheers,
TInk
|
|
|
04-16-2003, 07:38 AM
|
#7
|
LQ Newbie
Registered: Apr 2003
Posts: 4
Original Poster
Rep:
|
That's my problem. When I try to link gdk_pixbuf-2.0 and gdk-x11-2.0 statically I receive all of those errors. I'm beginning to wonder if it's even possible, but I am hopeful it is and someone out there has done it and can help me.
Joe-E
|
|
|
10-21-2004, 01:05 AM
|
#8
|
LQ Newbie
Registered: Apr 2004
Posts: 8
Rep:
|
Static compilation
The library included in ur stitic compilation program may be interdependent so try to change there position and then try ..... u can find out .la file of the same library on which libs this lib depends .... hope this will solve ur problem..
|
|
|
All times are GMT -5. The time now is 12:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|