Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

I want to link wxWidgets-libraries statically

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
Heinzi
n00b
n00b
Posts: 31
Joined: Sat May 26, 2007 4:20 pm

I want to link wxWidgets-libraries statically

  • Quote

Post by Heinzi » Sat Sep 15, 2007 5:42 pm

Hello,

My Gentoo (amd64) is up to date, I have the newest (not masked) versions of all installed applications. That means I'm using wxWidgets 2.6, not 2.8, because 2.8 is still masked ~amd64.
I programmed an application with wxWidgets 2.6 and compiled it with

Code: Select all

g++ `wx-config --libs --cppflags` *.cpp
It worked, I got an executable and I could run it -all was fine.
So I copied the file to another amd64 PC and wanted to run it. I was told:
error while loading shared libraries: libwx_gtk2u_xrc-2.6.so.0: cannot open shared object file: No such file or directory
On that PC wxWidgets isn't installed. I think the reason is, that wxWidgets links its libraries dynamically.
But I want my applications to run on any operating system (Windows too) without wxWidgets being installed there - that's the reason why I chose wxWidgets and not GTK+.
So I tried to link the wxWidgets libraries statically to my application with

Code: Select all

g++ -static `wx-config --libs --cppflags` *.cpp
and I got many compiler errors - it couldn't find my defined wxWidgets variables. So I asked google and got the following solution:

Code: Select all

g++ `wx-config --libs --cppflags --static` *.cpp
But even

Code: Select all

wx-config --static
doesn't work:
$ wx-config --static

Warning: No config found to match: /usr/bin/wx-config --static
in /usr/lib64/wx/config
If you require this configuration, please install the desired
library build. If this is part of an automated configuration
test and no other errors occur, you may safely ignore it.
You may use wx-config --list to see all configs available in
the default prefix.
Looks like my wxWidget installation hasn't the ability to link itself statically. I searched for other wxWidgets builds in the portage tree but didn't find any.

Code: Select all

equery uses wxGTK
didn't show me any helpful useflags like 'static' or whatever.
Is there a possibility to teach my wxWidgets to build itself statically?

-Heinzi
Top
Heinzi
n00b
n00b
Posts: 31
Joined: Sat May 26, 2007 4:20 pm

  • Quote

Post by Heinzi » Tue Sep 18, 2007 3:21 pm

When I build the app with anjuta IDE, the executable is much larger as when I build it by myself.
But I think that are other libraries that are included, because even the larger executable file aborts on other systems with the message that libwx_gtk2u_xrc-2.6.so.0 was not found.

Any idea how I could solve the problem and run wxWidgets based Apps on any PC without installing wxWidgets there? Isn't that the clue of wxWidgets?

-Heinzi
Top
didl
Retired Dev
Retired Dev
User avatar
Posts: 1106
Joined: Tue Sep 09, 2003 11:01 pm
Location: Pittsburgh, PA

  • Quote

Post by didl » Tue Sep 18, 2007 3:40 pm

If you want to build a static binary for your application you need to have
static wxWidgets libraries to link against (*.a versus *.so). I am not sure
if wxWidgets can be build statically, it may be possible.

Second, no matter if you succeed in linking your application statically
or not, it will only run on operating systems that use the ELF binary
ABI that linux uses. Hence, your binaries will run on linux, possibly
FreeBSD with kernel level ELF support but not Windows and clearly
not every PC out there.

The wxWidgets framework will allow you to write C++ code that will
(ideally) compile on all platforms that wxWidgets supports and then
have the platform's native look. But you most likely will have to have
wxWidgets installed on each of these platforms and recompile your
code for each of them.
Top
Heinzi
n00b
n00b
Posts: 31
Joined: Sat May 26, 2007 4:20 pm

  • Quote

Post by Heinzi » Tue Sep 18, 2007 6:57 pm

Second, no matter if you succeed in linking your application statically
or not, it will only run on operating systems that use the ELF binary
ABI that linux uses. Hence, your binaries will run on linux, possibly
FreeBSD with kernel level ELF support but not Windows and clearly
not every PC out there.
Yes I know that I cannot compile an application on one OS and use that executable on another OS.
But I want to compile my application on a Linux machine where wxWidgets is installed and that executable should be able to run on any Linux system.
I also want to compile the same application on a Windows machine where wxWidgets is installed and that win32-executable should be able to run on any Windows system.
But you most likely will have to have
wxWidgets installed on each of these platforms and recompile your
code for each of them.
I have wxWidgets installed on my compiler PC. But when I hand over my applications (as executables) to friends, they shouldn't need wxWidgets installed on their computer to run my executables.

Is there no workaround? Do I always need wxWidgets to run an application which is build with wxWidgets? I thought wxWidgets is kind of a wrapper, which wraps GTK+ on Linux and MFC on Windows. So the application would contain GTK+-Code when it's compiled on Linux and it would contain MFC-Code when it's compiled on Windows. Is that a misapprehension?
Top
didl
Retired Dev
Retired Dev
User avatar
Posts: 1106
Joined: Tue Sep 09, 2003 11:01 pm
Location: Pittsburgh, PA

  • Quote

Post by didl » Tue Sep 18, 2007 7:22 pm

But when I hand over my applications (as executables) to friends, they shouldn't need wxWidgets installed on their computer to run my executables.
If you compile static libs for wxWidgets and link your code against them you should be able to do
this. I've done it for Qt in the (very distant) past.
Top
Heinzi
n00b
n00b
Posts: 31
Joined: Sat May 26, 2007 4:20 pm

  • Quote

Post by Heinzi » Tue Sep 18, 2007 9:22 pm

Exactly there's my problem. I don't know how to compile my application with static wxWidgets libs. The gcc-parameter -static doesn't work and "wx-config --static" told me that I need the wxWidgets static libs which aren't installed (see my first post on this topic).
Can I install the static wxWidgets-libs with portage?
Top
didl
Retired Dev
Retired Dev
User avatar
Posts: 1106
Joined: Tue Sep 09, 2003 11:01 pm
Location: Pittsburgh, PA

  • Quote

Post by didl » Wed Sep 19, 2007 1:05 pm

I don't think the ebuild supports this so you will have to change
it yourself or build it "by hand". There typically is a configure option
such as "enable-static" or "disable-shared".
Top
Heinzi
n00b
n00b
Posts: 31
Joined: Sat May 26, 2007 4:20 pm

  • Quote

Post by Heinzi » Wed Sep 19, 2007 3:33 pm

ok thank you. I will try to change the ebuild though I don't know much about ebuilds ;)
Top
Post Reply

8 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic