473,626 Members | 3,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

static linking of C++ libraries with gcc/g++


I want to link the C++ standard libraries statically for my application
because I don't space for the .so files on my target platform.

After quite a bit of searching, I found very little information that
was helpful. The best information I found was at this link
http://fresco.org/~njs/c++-without-stdc++

I followed the approach here and used -nostdlib to disable the default
linking. Instead I use the options:

-lsupc++ -lgcc -lgcc_eh -lc -lgcc -lgcc_eh

where -lgcc -lgcc_eh has to be repeated twice for some reason.

In summary the linker options I used are

-Wl,-Bstatic -lsupc++ -lgcc -lgcc_eh -lc -lgcc -lgcc_eh

followed by -Wl,-Bdynamic to link dynamically with some other
libraries. The problem I found is this:

warning: cannot find entry symbol _start; defaulting to 000877e0

Can anyone suggest why this might be occurring? OR give me some
pointers to some useful information on the topic of static link for
C++?

Thanks,
DS.

Jul 22 '05 #1
3 10310
da***********@e xcite.com wrote:
I want to link the C++ standard libraries statically for my application because I don't space for the .so files on my target platform.
That's an interesting assessment: you don't have space for the shared
object but you expect to have space for the application with the
moral equivalent being linked in? I'd consider this to be relatively
unlikely: this only works if you don't use major parts of the standard
library (neither explicitly nor implicitly by other stuff you use).
After quite a bit of searching, I found very little information that
was helpful. The best information I found was at this link
http://fresco.org/~njs/c++-without-stdc++

I followed the approach here and used -nostdlib to disable the default linking. Instead I use the options:

-lsupc++ -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
Of course, this whole gcc stuff is environment specific and off-topic
in comp.lang.c++ and probably also in most of the other forums...
However: why don't you use the option "-static"? This links the
standard
library statically as long as you have a static version thereof. Use of
-nostdlib is more intended to people using a different implementation
of
the standard C++ library and is typically a little bit more involved
than just that...
warning: cannot find entry symbol _start; defaulting to 000877e0


I think this symbol and a few others you'll need are defined in crt1.o,
crti.o, and crtn.o. Why these symbols are not included when specifying
the option -nostdlib, I don't know.
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 22 '05 #2
da***********@e xcite.com wrote:
I want to link the C++ standard libraries statically


I thought they were! If static here means "does not change while the
program is executing", as opposed to dynamic ( Microsoft dll's et al ).

--

Cheers
--
Hewson::Mike
"This letter is longer than usual because I lack the time to make it
shorter" - Blaise Pascal
Jul 22 '05 #3
GTO
I am reading your post via comp.lang.c++.

You forgot to add gnu.gcc.help to your cross-posting. The right choice of
group is half the answer. The audience of gnu.gcc.help should be of more
help.

BTW, buy yourself a copy of Kurt Wall and William von Hagen's The Definitive
Guide to GCC, Apress, 2004.

Gregor

PS: Did you try -static?

<da***********@ excite.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .

I want to link the C++ standard libraries statically for my application
because I don't space for the .so files on my target platform.

After quite a bit of searching, I found very little information that
was helpful. The best information I found was at this link
http://fresco.org/~njs/c++-without-stdc++

I followed the approach here and used -nostdlib to disable the default
linking. Instead I use the options:

-lsupc++ -lgcc -lgcc_eh -lc -lgcc -lgcc_eh

where -lgcc -lgcc_eh has to be repeated twice for some reason.

In summary the linker options I used are

-Wl,-Bstatic -lsupc++ -lgcc -lgcc_eh -lc -lgcc -lgcc_eh

followed by -Wl,-Bdynamic to link dynamically with some other
libraries. The problem I found is this:

warning: cannot find entry symbol _start; defaulting to 000877e0

Can anyone suggest why this might be occurring? OR give me some
pointers to some useful information on the topic of static link for
C++?

Thanks,
DS.

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2871
by: Grzegorz Dostatni | last post by:
Cheers. First what I am trying to do: I am trying to create a version of pytho23.dll that contains everything inside of it. It is staticaly linked. It also needs to contain the qt library. For this I am trying to work off of instructions designed for unix/linux using visual c++.net and gui. I can compile basic python - that's not a problem. Once I add the paths and dependencies for qt (as well as modifying the config.c) I get an error:
3
2600
by: Rickard Lind | last post by:
Is there any way to build the python executable statically and still be able to load modules built as shared libraries? I'm trying to run python scripts on a stripped down FreeBSD (4.9) machine which has no shared system libraries so I want to link it statically against libc et al, but it would be nice to still be able to load modules which were built as shared libraries. In particular I have a library for which I've generated a wrapper...
15
2307
by: Notre Poubelle | last post by:
Hello, I have a large legacy MFC application. As is typical, there is an executable along with several MFC DLLs. One of these DLLs is created by staticly linking in many libraries resulting in one very large DLL that has the bulk of the code. I've downloaded the MFCWinFormsSample.EXE and have noticed that the main app could stay as a native executable (i.e. no CLR support) whereas the various ..DLLs can be marked as having CLR...
3
5106
by: Charles Nicholson | last post by:
Hello all- I have some static C++ libraries that I wrote in VS2003 but which upgraded fine when i went to VS2005 Pro. In them i overload the global versions of operators new, new, delete, and delete. I also use the STL and parts of boost (shared_ptr<> and weak_ptr<>) pretty heavily. They have dependencies on various windows libs (dbghelp, winsock, etc...). These static libraries have no common runtime support at all and use the...
2
3474
by: vasantha2712 | last post by:
I am trying to integrate Log4cpp in our project. I was able to successfully build the log4cpp using the command : ./configure --disable-static . I have included the log4cpp libraries path in our project . i was able to log and trace also. But my problem is static linking : i mean how do build log4cpp and create static libraries. I have tried building the log4cpp with the command : ./configure --enable-static , But when i try t oinclude...
4
1555
by: nishantb | last post by:
I had posted simillar question some time back. i want to link some libraries statically on NT. currently, product execute command simillar to following. link /STACK:0x20000 /libpath:D:/lib a.lib /out:out.exe x.obj a.lib here a.lib is library , out.exe is executable 1. first of all, i think this itself is static linking. because, this link commad is used compile time only. am i correct? 2. If not, ( and i am surely wrong, because...
1
1515
by: barcaroller | last post by:
This is not a language-specific question. I have an executable that is supposed to link to both static and shared libraries at the same time. Most of these libraries come in both flavours and the linker is not choosing the right ones by default. The problem is that when I use options like '-static' the linker will try too link all libraries as static (which I don't want). I've tried various combinations of '-static' and '-shared' to no...
0
2192
by: abarun22 | last post by:
HI I am new to SWIG & Python and right now i am in the process of wrapping some "C" functionalities present in a static library for python. I do have my C file "name.c" which just contains some helper functions. I tried to link my object files (e.g name.o & name_wrap.o) with the static libraries (whose functionalities need to be wrapped) to form a shared library that can be imported from Python. While doing so i cannot be able to access...
20
4284
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. How can I dynamically load a LIB file and access all its functions? Surely someone has solved similar task? My intention is to use a Forth system for programming the controller,
0
8269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8203
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8642
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.