static build
I would like to build a slimmed-down version of OpenVPN for armv6 - would that be easy to achieve?
My aim is to deploy it on my android device (I don't trust the version in existence there, so by statically building OpenVPN I won't be dependent on the bionic toolchain). Has this been attempted before? Many thanks!
Hello,
I am working on a new build system for OpenVPN, you can check it[1] out.
To cross compile master to arm in static, do:
$ git clone git://github.com/alonbl/openvpn-build.git $ cd openvpn-build/generic $ CHOST="arm-unknown-linux-gnueabi" CBUILD="x86_64-pc-linux-gnu" DO_STATIC=1 ./build
It will create static dependencies, but dynamic libc, if you want really static use DO_REALLY_STATIC=1.
Alon
[1] https://github.com/alonbl/openvpn-build
Quoted 17 lines · Mr Dash Four
I would like to build a slimmed-down version of OpenVPN for armv6 - would that be easy to achieve?
My aim is to deploy it on my android device (I don't trust the version in existence there, so by statically building OpenVPN I won't be dependent on the bionic toolchain). Has this been attempted before? Many thanks!
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 12 lines
I am working on a new build system for OpenVPN, you can check it[1] out.
To cross compile master to arm in static, do:
$ git clone git://github.com/alonbl/openvpn-build.git $ cd openvpn-build/generic $ CHOST="arm-unknown-linux-gnueabi" CBUILD="x86_64-pc-linux-gnu" DO_STATIC=1 ./buildIt will create static dependencies, but dynamic libc, if you want really static use DO_REALLY_STATIC=1.
Thanks Alon, I'll give it a try.
I'll probably use REALLY_STATIC as well, because, as I already pointed out, the libc is bionic and I do not wish to rely on it - I want everything openvpn depends on to be included in the binary. I know it could be massive in size, but I am prepared to take that hit. I also take it I can still run configure with the desired configuration options, is that correct?
Quoted 8 lines
To cross compile master to arm in static, do:
$ git clone git://github.com/alonbl/openvpn-build.git $ cd openvpn-build/generic $ CHOST="arm-unknown-linux-gnueabi" CBUILD="x86_64-pc-linux-gnu" DO_STATIC=1 ./buildIt will create static dependencies, but dynamic libc, if you want really static use DO_REALLY_STATIC=1.
This build fails at the same point as in my srpm static compilation:
checking for lzo1x_1_15_compress in -llzo2... no
checking for lzo1x_1_15_compress in -llzo... no
configure: error: LZO headers were found but LZO library was not found
FATAL: Configure openvpn
Reason being, I suspect, that the lzo static libraries cannot be found (strange as the compilation succeeded).
Quoted 10 lines · Mr Dash Four
Quoted 8 lines
To cross compile master to arm in static, do:
$ git clone git://github.com/alonbl/openvpn-build.git $ cd openvpn-build/generic $ CHOST="arm-unknown-linux-gnueabi" CBUILD="x86_64-pc-linux-gnu" DO_STATIC=1 ./buildIt will create static dependencies, but dynamic libc, if you want really static use DO_REALLY_STATIC=1.
This build fails at the same point as in my srpm static compilation:
Quoted 7 lines
checking for
lzo1x_1_15_compressin -llzo2... no
checking forlzo1x_1_15_compressin -llzo... no
configure: error: LZO headers were found but LZO library was not found
FATAL: Configure openvpnReason being, I suspect, that the lzo static libraries cannot be found (strange as the compilation succeeded).
I need tmp/openvpn/config.log
Better to have the complete build output...
Alon.
Quoted 7 lines
Quoted 3 lines
Reason being, I suspect, that the lzo static libraries cannot be found (strange as the compilation succeeded).
I need tmp/openvpn/config.log
Better to have the complete build output...
This was done in mock environment (both the rpm and "normal" build). When I did this from outside, using a specific arm cross-toolchain, the build succeeded, *but* the package created does not contain static openvpn - it still needs all of its dependencies (though them being statically-build components, like lzo etc). The output produced from your build script seems to be an archive, presumably containing all the files openvpn needs, spread across multiple directories (I am also not sure whether openvpn produced in this way won't need its libgc library).
I suspect all I need to do is to unpack this archive to the target, but that won't do me any good at all, because my root system on the android device is squashfs (read-only) and whatever I do with it (provided I succeed) will be destroyed the next time I reboot the device. What I need is a single openvpn executable, so that I could just place it somewhere in my path and fire it off.
I was able to slightly amend the running order of openvpn compilation process and succeeded in building a single, statically-linked openvpn executable for my android device.
The error your build script has with this is that the last statement which links all objects into the openvpn executable should contain "-static", "-static-libgcc" along with "-ldl" - currently you don't have that and the openvpn executable produced is about 700kB, still needing its static libraries at the very least.
When openvpn is statically linked in the way I just described, the file produced is about 7MB, coming down to about 1.7MB after stripping. Copying this single file to my android device (and briefly testing it) seems to have done the trick.
One drawback from this, which is valid for *all* statically-linked executables in this way, is that there are some arch-dependent functions, like "gethostbyname", which are implemented, possibly in a different way in different environments, hence when I statically link and produce one single monolithic executable in such a way I get a warning from the linker, but since I am not likely to use such functions, I think there is nothing to worry about.
Hello,
You can check if executable is static by using arm-unknown-linux-gnueabi-readelf --relocas.
The fact that the archive has a lot of files does not mean the openvpn is not static.
Anyway it is working at my side, and it is a standard process. You can adjust the script for your needs.
Alon.
Quoted 48 lines · Mr Dash Four
Quoted 9 lines
Quoted 4 lines
Reason being, I suspect, that the lzo static libraries cannot be found (strange as the compilation succeeded).
I need tmp/openvpn/config.log
Better to have the complete build output...This was done in mock environment (both the rpm and "normal" build). When I did this from outside, using a specific arm cross-toolchain, the build succeeded, *but* the package created does not contain static openvpn - it still needs all of its dependencies (though them being statically-build components, like lzo etc). The output produced from your build script seems to be an archive, presumably containing all the files openvpn needs, spread across multiple directories (I am also not sure whether openvpn produced in this way won't need its libgc library).
I suspect all I need to do is to unpack this archive to the target, but that won't do me any good at all, because my root system on the android device is squashfs (read-only) and whatever I do with it (provided I succeed) will be destroyed the next time I reboot the device. What I need is a single openvpn executable, so that I could just place it somewhere in my path and fire it off.
I was able to slightly amend the running order of openvpn compilation process and succeeded in building a single, statically-linked openvpn executable for my android device.
The error your build script has with this is that the last statement which links all objects into the openvpn executable should contain "-static", "-static-libgcc" along with "-ldl" - currently you don't have that and the openvpn executable produced is about 700kB, still needing its static libraries at the very least.
When openvpn is statically linked in the way I just described, the file produced is about 7MB, coming down to about 1.7MB after stripping. Copying this single file to my android device (and briefly testing it) seems to have done the trick.
One drawback from this, which is valid for *all* statically-linked executables in this way, is that there are some arch-dependent functions, like "gethostbyname", which are implemented, possibly in a different way in different environments, hence when I statically link and produce one single monolithic executable in such a way I get a warning from the linker, but since I am not likely to use such functions, I think there is nothing to worry about.
Quoted 6 lines
You can check if executable is static by using arm-unknown-linux-gnueabi-readelf --relocas.
The fact that the archive has a lot of files does not mean the openvpn is not static.
Well, I don't really know what you understand "static linking" to be, but to me it means that all external functions, subroutines etc, which are resolved at compile-time, are copied into a target application by the gcc linker, producing an object file and then a stand-alone executable ("stand-alone" being the key word here!). Your build script, evidently, does not do that and I already pointed out the changes you may need to make to allow a *stand-alone* openvpn executable to be produced.
If you believe "static linking" to mean something else from what I described above, please enlighten us all!
If I have to deploy additional files alongside openvpn, then I may as well have it dynamically linked and deploy the entire dependencies chain (using ldd as guidance). The reason I can't/won't do that is because to satisfy this, I have to 1) spend a lot of my time digging out dependencies, without the guarantee that it would ever work, and 2) as my rootfs is read-only, whatever I do it will be instantly lost on reboot, so the whole exercise would be utterly pointless.
Quoted 3 lines
Anyway it is working at my side, and it is a standard process. You can adjust the script for your needs.
I already did, you may as well do the same and make the changes I suggested earlier for the "really_static" option to really work, because, as it stands, "really_static" isn't so as openvpn still needs external files to operate.
$ git clone https://github.com/alonbl/openvpn-build.git $ cd openvpn.build $ DO_REALLY_STATIC=1 IMAGEROOT=`pwd`/image-arm-static CHOST=arm-unknown-linux-gnueabi CBUILD=x86_64-pc-linux-gnu ./build $ file image-arm-static/openvpn/sbin/openvpn image-arm-static/openvpn/sbin/openvpn: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped $ ls -hla image-arm-static/openvpn/sbin/openvpn -rwxr-xr-x 1 alonbl alonbl 2.3M Feb 26 17:09 image-arm-static/openvpn/sbin/openvpn $ arm-unknown-linux-gnueabi-objdump --dynamic-reloc image-arm-static/openvpn/sbin/openvpn
image-arm-static/openvpn/sbin/openvpn: file format elf32-littlearm
arm-unknown-linux-gnueabi-objdump:
image-arm-static/openvpn/sbin/openvpn: not a dynamic object arm-unknown-linux-gnueabi-objdump:
image-arm-static/openvpn/sbin/openvpn: Invalid operation
Quoted 35 lines · Mr Dash Four
Quoted 6 lines
You can check if executable is static by using arm-unknown-linux-gnueabi-readelf --relocas.
The fact that the archive has a lot of files does not mean the openvpn is not static.Well, I don't really know what you understand "static linking" to be, but to me it means that all external functions, subroutines etc, which are resolved at compile-time, are copied into a target application by the gcc linker, producing an object file and then a stand-alone executable ("stand-alone" being the key word here!). Your build script, evidently, does not do that and I already pointed out the changes you may need to make to allow a *stand-alone* openvpn executable to be produced.
If you believe "static linking" to mean something else from what I described above, please enlighten us all!
If I have to deploy additional files alongside openvpn, then I may as well have it dynamically linked and deploy the entire dependencies chain (using ldd as guidance). The reason I can't/won't do that is because to satisfy this, I have to 1) spend a lot of my time digging out dependencies, without the guarantee that it would ever work, and 2) as my rootfs is read-only, whatever I do it will be instantly lost on reboot, so the whole exercise would be utterly pointless.
Quoted 3 lines
Anyway it is working at my side, and it is a standard process. You can adjust the script for your needs.
I already did, you may as well do the same and make the changes I suggested earlier for the "
really_static" option to really work, because, as it stands, "really_static" isn't so as openvpn still needs external files to operate.
Quoted 4 lines
arm-unknown-linux-gnueabi-objdump:
image-arm-static/openvpn/sbin/openvpn: Invalid operation
Huh?
Have you altered the sources/makefiles of openvpn or any of the dependent libraries (lzo, openssh etc) by any chance? I noticed you are applying a single patch to the lzo source, which I had to re-adjust as I was using a newer version, but I am not aware of any alterations that you have made to these - if you have done so, please state what these alterations are?
I don't know whether you've altered the original build script or not, but the end result, before applying my changes, clearly produces openvpn executable, which has external dependencies on all statically-produced .la files/libraries (lzo, openssh etc) - they are all packed in the .tar archive produced at the end of this script (located in the /lib directory to be more precise).
I don't know what you are trying to prove by posting the above though - the final gcc linker call, which produces the openvpn executable before packing the image does *not* have any static-linking related options whatsoever! I could post the exact gcc command line, but I do not have access to that machine at present.
These options are, as I already pointed out previously, "-static", "-static-gcc" as well as "-ldl" - the latter being a new dependencies, necessary to offset the fact that all dl* calls (dlopen etc) won't be satisfied if static linking is invoked, so this external library needs to be included so that static linking succeeds, otherwise you will get "unknown symbol" errors.
Again, all that is provided you haven't altered any of the core source and/or makefile scripts in any way (I haven't used your own - alonbv - repos to download these, but downloaded these packages from their original source where these projects are created - openvpn.net, openssh.org etc). If you have made such alterations, I'd like to know what changes have you made?
This is my last reply on this thread.
What I show you is that without any change I compile static code for arm using cross compiler.
I guess I am far more knowledgeable than you to tell me what is right, and I disapprove your comments and language.
So the answer to your initial question: yes, openvpn can be compiled statically. Figure it out your-self.
Quoted 39 lines · Mr Dash Four
Quoted 4 lines
arm-unknown-linux-gnueabi-objdump:
image-arm-static/openvpn/sbin/openvpn: Invalid operationHuh?
Have you altered the sources/makefiles of openvpn or any of the dependent libraries (lzo, openssh etc) by any chance? I noticed you are applying a single patch to the lzo source, which I had to re-adjust as I was using a newer version, but I am not aware of any alterations that you have made to these - if you have done so, please state what these alterations are?
I don't know whether you've altered the original build script or not, but the end result, before applying my changes, clearly produces openvpn executable, which has external dependencies on all statically-produced .la files/libraries (lzo, openssh etc) - they are all packed in the .tar archive produced at the end of this script (located in the /lib directory to be more precise).
I don't know what you are trying to prove by posting the above though - the final gcc linker call, which produces the openvpn executable before packing the image does *not* have any static-linking related options whatsoever! I could post the exact gcc command line, but I do not have access to that machine at present.
These options are, as I already pointed out previously, "-static", "-static-gcc" as well as "-ldl" - the latter being a new dependencies, necessary to offset the fact that all dl* calls (dlopen etc) won't be satisfied if static linking is invoked, so this external library needs to be included so that static linking succeeds, otherwise you will get "unknown symbol" errors.
Again, all that is provided you haven't altered any of the core source and/or makefile scripts in any way (I haven't used your own - alonbv - repos to download these, but downloaded these packages from their original source where these projects are created - openvpn.net, openssh.org etc). If you have made such alterations, I'd like to know what changes have you made?
Quoted 9 lines
This is my last reply on this thread.
What I show you is that without any change I compile static code for arm using cross compiler.
I guess I am far more knowledgeable than you to tell me what is right, and I disapprove your comments and language.So the answer to your initial question: yes, openvpn can be compiled statically. Figure it out your-self.
Timeout guys, getting personal does not help.
Mr Dash Four: could you try following the steps Alon gave in his earlier mail to see if it works for you? The buildsystem fetches the dependencies from standard URLs, see "openvpn-build/generic/build.vars".
Best regards,
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock
Quoted 48 lines
Quoted 31 lines · Mr Dash Four
Quoted 3 lines
arm-unknown-linux-gnueabi-objdump:
image-arm-static/openvpn/sbin/openvpn: Invalid operationHuh?
Have you altered the sources/makefiles of openvpn or any of the dependent libraries (lzo, openssh etc) by any chance? I noticed you are applying a single patch to the lzo source, which I had to re-adjust as I was using a newer version, but I am not aware of any alterations that you have made to these - if you have done so, please state what these alterations are?
I don't know whether you've altered the original build script or not, but the end result, before applying my changes, clearly produces openvpn executable, which has external dependencies on all statically-produced .la files/libraries (lzo, openssh etc) - they are all packed in the .tar archive produced at the end of this script (located in the /lib directory to be more precise).
I don't know what you are trying to prove by posting the above though - the final gcc linker call, which produces the openvpn executable before packing the image does *not* have any static-linking related options whatsoever! I could post the exact gcc command line, but I do not have access to that machine at present.
These options are, as I already pointed out previously, "-static", "-static-gcc" as well as "-ldl" - the latter being a new dependencies, necessary to offset the fact that all dl* calls (dlopen etc) won't be satisfied if static linking is invoked, so this external library needs to be included so that static linking succeeds, otherwise you will get "unknown symbol" errors.
Quoted 6 lines
Again, all that is provided you haven't altered any of the core source and/or makefile scripts in any way (I haven't used your own - alonbv - repos to download these, but downloaded these packages from their original source where these projects are created - openvpn.net, openssh.org etc). If you have made such alterations, I'd like to know what changes have you made?
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 5 lines
Mr Dash Four: could you try following the steps Alon gave in his earlier mail to see if it works for you? The buildsystem fetches the dependencies from standard URLs, see "openvpn-build/generic/build.vars".
Except that they are not "standard", at least not all of them.
The openvpn url in build.vars from Alon's project defaults to "https://github.com/downloads/alonbl/openvpn/openvpn-${OPENVPN_VERSION}.tar.gz". As evident, the openvpn source refers to "openvpn-${OPENVPN_VERSION}.tar.gz" (${OPENVPN_VERSION} itself defaults to "2.3_alpha1").
Naturally, one would assume that this is the standard openvpn source version 2.3 alpha1, hence I did not use "https://github.com/downloads/alonbl" - a private github repository of Alon himself (nothing whatsoever to do with openvpn), but opted to download and archive that same openvpn version from the main openvpn.net git repository, using the appropriate tag ("v2.3_alpha1"). It is worth noting that I did exactly the same with all other source dependencies, like lzo, openssh etc (something I have made very clear in one of my last posts) and downloaded their corresponding sources from "official" repositories directly.
That, I thought, rather naively as it turned out, should get me the desired version of openvpn as I assumed that the openvpn source code "offered" by Alon and the official one were exactly the same. How wrong was I!
The Alon's version of "openvpn 2.3_alpha1" is very different from "openvpn 2.3_alpha1" downloaded from the official openvpn git repository using the same tag! If you do not believe me - take a look for yourself.
I don't mind Alon (or anybody else for that matter) altering the openvpn source code and its structure, because at the end of the day it is an open source project, but to give it a name like "openvpn 2.3_alpha1" clearly implying that this is the official "openvpn 2.3_alpha1" source without explicitly stating that there were alterations/changes made to that source code is clearly very misleading and in this respect Alon is no better than the scum out there offering "loaded" source code of well-known software products to naive idiots like myself, stupid enough to download it.
As for the main topic of this thread - static build of openvpn, the following is the last gcc command line which links and creates the final openvpn executable (again, using the "standard" openvpn source and not the mickey-mouse version Alon is "offering") - judge for yourself whether this produces a monolithic, statically-linked openvpn executable:
arm-pc-linux-gnueabi-gcc -g -O2 -o openvpn base64.o buffer.o crypto.o dhcp.o error.o event.o fdmisc.o forward.o fragment.o gremlin.o helper.o httpdigest.o lladdr.o init.o interval.o list.o lzo.o manage.o mbuf.o misc.o mroute.o mss.o mtcp.o mtu.o mudp.o multi.o ntlm.o occ.o pkcs11.o openvpn.o options.o otime.o packet_id.o perf.o pf.o ping.o plugin.o pool.o proto.o proxy.o ieproxy.o ps.o push.o reliable.o route.o schedule.o session_id.o shaper.o sig.o socket.o socks.o ssl.o status.o tun.o win32.o cryptoapi.o memcmp.o -lssl -lcrypto -llzo2
As I already pointed out in my previous post, to produce a proper, statically-linked openvpn executable, the following options need to be added to the above command line:
"-static", "-static-libgcc" and "-ldl" at the very end, in order to avoid "unknown symbol" link errors like:
"undefined reference to dlopen'", "undefined reference to dlsym'", "undefined reference to dladdr'" and "undefined reference to dlerror'".
To conclude this, I am very happy that I was finally able to produce openvpn, which is statically-linked so that I could avoid all bionic dependencies or depending on any other android-based stuff. Now I can, hopefully, use this on my android device without further problems, fingers crossed!
Hi,
Quoted 3 lines · Mr Dash Four
The Alon's version of "openvpn 2.3_alpha1" is very different from "openvpn 2.3_alpha1" downloaded from the official openvpn git repository using the same tag! If you do not believe me - take a look for yourself.
This is well understood.
The C sources are (basically) the same, but in Alon's tree, the build system has been re-built from scratch, from "something that sort-of works" to something new, which is more flexible, and (most important here) handles cross-building including all the dependencies in a fully automated way.
As soon as the rest of the OpenVPN developers agree on all the details, Alon's changes will be integrated into the "main" openvpn git.
Quoted 9 lines
I don't mind Alon (or anybody else for that matter) altering the openvpn source code and its structure, because at the end of the day it is an open source project, but to give it a name like "openvpn 2.3_alpha1" clearly implying that this is the official "openvpn 2.3_alpha1" source without explicitly stating that there were alterations/changes made to that source code is clearly very misleading and in this respect Alon is no better than the scum out there offering "loaded" source code of well-known software products to naive idiots like myself, stupid enough to download it.
Alon's new build system was announced here on the list just a few days ago.
Quoted 5 lines
As for the main topic of this thread - static build of openvpn, the following is the last gcc command line which links and creates the final openvpn executable (again, using the "standard" openvpn source and not the mickey-mouse version Alon is "offering") - judge for yourself whether this produces a monolithic, statically-linked openvpn executable:
We don't care. Really. Alon's build system is where the journey is going to, and we are not going to do piecemeal fixes in the existing build system.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 9 lines
Quoted 5 lines
Mr Dash Four: could you try following the steps Alon gave in his earlier mail to see if it works for you? The buildsystem fetches the dependencies from standard URLs, see "openvpn-build/generic/build.vars".
Except that they are not "standard", at least not all of them. The Alon's version of "openvpn 2.3_alpha1" is very different from "openvpn 2.3_alpha1" downloaded from the official openvpn git repository using the same tag! If you do not believe me - take a look for yourself.
I hear you. as you probably know, Alon's been working on major overhaul of the buildsystem, which affects tons of source code files. In these cases forking the project temporarily into a separate Git repository is a standard practice. His patches are now being reviewed and merged into the official Git repository.
That said, I agree the naming is misleading.
Quoted 5 lines
To conclude this, I am very happy that I was finally able to produce openvpn, which is statically-linked so that I could avoid all bionic dependencies or depending on any other android-based stuff. Now I can, hopefully, use this on my android device without further problems, fingers crossed!
Good to hear you got it working!
Take care,
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock