473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 10290
da***********@excite.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.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #2
da***********@excite.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.googlegr oups.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
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...
3
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...
15
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...
3
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...
2
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...
4
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...
1
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...
0
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...
20
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. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.