Overview
Features
Download
Documentation
Community
Add-Ons & Services

How to force static linking?

Please post support and help requests here.

How to force static linking?

Postby tomy » 02 Apr 2012, 13:10

Hey,
I've compiled POCO and everything works great.
Anyhow, I'm wondering how to force Visual Studio to link ALL the POCO libraries statically... I want zero-dependencies :). Any ideas?
thank you!
tomy
 
Posts: 5
Joined: 01 Apr 2012, 12:28

Re: How to force static linking?

Postby alex » 02 Apr 2012, 14:13

See buildwin.cmd:

Code: Select all
LINKMODE static_mt|static_md|shared|all
alex
 
Posts: 1087
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to force static linking?

Postby tomy » 02 Apr 2012, 21:40

If I understand right, as I did not set the LINKMODE, the POCO has compiled for ALL the architectures. (a used "buildwin.cmd 100"). So it is compiled for the static linkmode too. What should I do in a Visual Studio now?
tomy
 
Posts: 5
Joined: 01 Apr 2012, 12:28

Re: How to force static linking?

Postby alex » 02 Apr 2012, 21:50

Static libraries (*.lib) will be in $POCO_BASE/lib directory. Link with them.
alex
 
Posts: 1087
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to force static linking?

Postby killerbot » 03 Apr 2012, 15:20

semi related, how can we avoid the debug libraries from being build (regular make file system, not vs build).
Release is sufficient in our use case, so we might +- 1/2 build time ;-)
killerbot
 
Posts: 66
Joined: 03 Dec 2009, 12:55

Re: How to force static linking?

Postby alex » 03 Apr 2012, 15:30

alex
 
Posts: 1087
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to force static linking?

Postby killerbot » 03 Apr 2012, 22:33

I have tried :
Code: Select all
make static_release


But this doesn't seem to work ==> make: *** No rule to make target `static_release'. Stop.
killerbot
 
Posts: 66
Joined: 03 Dec 2009, 12:55

Re: How to force static linking?

Postby alex » 11 Apr 2012, 05:03

not quite sure, it looks like there is no such target in Makefile indeed; perhaps Guenter can shed some light? Id commit a patch but I'm not sure whether I'm missing something.

In the meantime, this workaround should do:

Code: Select all
$POCO_BASE/.configure --static


and then add static target(s):

Code: Select all
-.PHONY: all libexecs cppunit tests samples clean distclean install
+.PHONY: all libexecs cppunit tests samples clean distclean install static_release

+static_release: libexecs
alex
 
Posts: 1087
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to force static linking?

Postby alex » 16 May 2012, 04:12

after a more careful look, here's what you need to do:

Code: Select all
$POCO_BASE/.configure --static
make -s poco


There is, however, another problem with building static on linux:

Code: Select all
** Building executable (release) /home/parallels/trunk/Foundation/testsuite/bin/Linux/x86_64/static/testrunner
/home/parallels/trunk/lib/Linux/x86_64/libPocoFoundation.a(SharedLibrary.o): In function `Poco::SharedLibraryImpl::loadImpl(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
SharedLibrary.cpp:(.text+0x123): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/parallels/trunk/lib/Linux/x86_64/libPocoFoundation.a(Path.o): In function `Poco::PathImpl::homeImpl()':
Path.cpp:(.text+0x218): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
** Creating dependency info for src/TestLibrary.cpp
** Compiling src/TestPlugin.cpp (debug, shared)
** Compiling src/TestLibrary.cpp (debug, shared)
** Building dynamic library (debug, static) /home/parallels/trunk/Foundation/testsuite/bin/Linux/x86_64/static/TestLibraryd.so
/usr/bin/ld: /home/parallels/trunk/lib/Linux/x86_64/libPocoFoundationd.a(Exception.o): relocation R_X86_64_32S against `vtable for Poco::Exception' can not be used when making a shared object; recompile with -fPIC
/home/parallels/trunk/lib/Linux/x86_64/libPocoFoundationd.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [/home/parallels/trunk/Foundation/testsuite/bin/Linux/x86_64/static/TestLibraryd.so] Error 1
make[1]: *** [projects] Error 2
make: *** [Foundation-tests] Error 2
parallels@ubuntu:~/trunk$ g++ --version
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
alex
 
Posts: 1087
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron