Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building Static/Portable #84

Open
Anonymous3-a opened this issue Dec 31, 2023 · 5 comments
Open

Building Static/Portable #84

Anonymous3-a opened this issue Dec 31, 2023 · 5 comments

Comments

@Anonymous3-a
Copy link

If I run sudo ./package-portable-linux.sh, it gives me this error:

Expand Block [Click]
./package-portable-linux.sh: line 5: cd: /usr/src/app: No such file or directory
Hit:1 cdrom://Trisquel 11.0 _aramo_ - Release amd64 (20230315) aramo InRelease
Hit:2 http://archive.trisquel.org/trisquel aramo InRelease
Hit:3 http://archive.trisquel.org/trisquel aramo-updates InRelease
Hit:4 http://archive.trisquel.org/trisquel aramo-security InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
325 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  python3-software-properties software-properties-qt
The following packages will be upgraded:
  python3-software-properties software-properties-common software-properties-qt
3 upgraded, 0 newly installed, 0 to remove and 322 not upgraded.
Need to get 119 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.trisquel.org/trisquel aramo-updates/main amd64 software-properties-common all 0.99.22.8+11.0trisquel13 [64.2 kB]
Get:2 http://archive.trisquel.org/trisquel aramo-updates/main amd64 software-properties-qt all 0.99.22.8+11.0trisquel13 [25.7 kB]
Get:3 http://archive.trisquel.org/trisquel aramo-updates/main amd64 python3-software-properties all 0.99.22.8+11.0trisquel13 [29.3 kB]
Fetched 119 kB in 0s (288 kB/s)                       
(Reading database ... 228949 files and directories currently installed.)
Preparing to unpack .../software-properties-common_0.99.22.8+11.0trisquel13_all.deb ...
Unpacking software-properties-common (0.99.22.8+11.0trisquel13) over (0.99.22.6+11.0trisquel12) ...
Preparing to unpack .../software-properties-qt_0.99.22.8+11.0trisquel13_all.deb ...
Unpacking software-properties-qt (0.99.22.8+11.0trisquel13) over (0.99.22.6+11.0trisquel12) ...
Preparing to unpack .../python3-software-properties_0.99.22.8+11.0trisquel13_all.deb ...
Unpacking python3-software-properties (0.99.22.8+11.0trisquel13) over (0.99.22.6+11.0trisquel12) ...
Setting up python3-software-properties (0.99.22.8+11.0trisquel13) ...
Setting up software-properties-common (0.99.22.8+11.0trisquel13) ...
Setting up software-properties-qt (0.99.22.8+11.0trisquel13) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for dbus (1.12.20-2ubuntu4.1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3+11.0trisquel2) ...
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu/ jammy main'
Description:
Toolchain test builds; see https://wiki.ubuntu.com/ToolChain

More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Adding repository.
Adding deb entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-aramo.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-aramo.list
Adding key to /etc/apt/trusted.gpg.d/ubuntu-toolchain-r-ubuntu-test.gpg with fingerprint 60C317803A41BA51845E371A1E9377A2BA9EF27F
Hit:1 cdrom://Trisquel 11.0 aramo - Release amd64 (20230315) aramo InRelease
Hit:2 http://archive.trisquel.org/trisquel aramo InRelease
Hit:3 http://archive.trisquel.org/trisquel aramo-updates InRelease
Hit:4 http://archive.trisquel.org/trisquel aramo-security InRelease
Get:5 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy InRelease [23.8 kB]
Get:6 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy/main amd64 Packages [15.5 kB]
Get:7 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy/main Translation-en [7808 B]
Fetched 47.1 kB in 2s (29.5 kB/s)
Reading package lists... Done
Hit:1 cdrom://Trisquel 11.0 aramo - Release amd64 (20230315) aramo InRelease
Hit:2 http://archive.trisquel.org/trisquel aramo InRelease
Hit:3 http://archive.trisquel.org/trisquel aramo-updates InRelease
Hit:4 http://archive.trisquel.org/trisquel aramo-security InRelease
Hit:5 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
333 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package g++-7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libglfw3-dev is already the newest version (3.3.6-1).
libgles2-mesa-dev is already the newest version (23.0.4-0ubuntu1~22.04.1).
0 upgraded, 0 newly installed, 0 to remove and 333 not upgraded.
./package-portable-linux.sh: line 17: python: command not found
update-alternatives: error: alternative path /usr/bin/gcc-7 doesn't exist
update-alternatives: error: alternative path /usr/bin/g++-7 doesn't exist
./package-portable-linux.sh: line 23: cd: opencv4/: No such file or directory
mkdir: cannot create directory ‘build-portable/’: File exists
./package-portable-linux.sh: line 25: /usr/local/bin/cmake: No such file or directory
make: *** No rule to make target 'install'. Stop.
./package-portable-linux.sh: line 28: cd: /usr/src/app: No such file or directory
mkdir: cannot create directory ‘build-portable/’: File exists
./package-portable-linux.sh: line 30: /usr/local/bin/cmake: No such file or directory
make: *** No rule to make target 'install'. Stop.


Is it not meant to make a static/portable executable?
Please tell me if there's a way, because I've been needing to rely on a livecd for a while and installing the dependencies repeatedly is getting very annoying.

@sz3
Copy link
Owner

sz3 commented Dec 31, 2023

It's not fully static, but it still will hopefully be helpful/useful.

  1. you may have figured this part out, but you'll need to download+extract opencv to opencv4/ first -- the last I tried was an older version (4.5.5), so YMMV with a newer one. The github workflow does download+extract for the emscripten build here:

    wget https://github.com/opencv/opencv/archive/refs/tags/4.5.5.zip
    unzip 4.5.5.zip
    mv opencv-4.5.5 opencv4

  2. that script is meant to be run inside a (ubuntu 16.04) docker container -- you can deconstruct it and run it outside one, but the commented out line at the top is how I run it:

docker run --mount type=bind,source="$(pwd)",target="/usr/src/app" -it ubuntu:16.04

(and then cd /usr/src/app && bash package-portable-linux.sh inside the docker shell)

Misc notes:

  • the goal is rely on the old portable linux hack using a mostly-static build on an ancient glibc. Hence using an ubuntu release from almost 8 years(!) ago...
  • if you're reading this and asking "why not musl?": I did experiment with a static musl build a few years ago, but gave up on it. It might be worth looking at again, tbh
  • For cimbar, the resulting linkage (ldd cimbar) should look something like:
	linux-vdso.so.1 (0x00007ffd68a7a000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3b9c6ed000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3b9c6ca000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3b9c6c0000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3b9c571000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3b9c37f000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3b9c723000)

  • I'm not sure how portable the resulting cimbar_send will be, since that still has dynamic linkage against libGL and GLFW 😱 ... but it's worth a shot.
  • looks like cimbar_recv has GLFW in its linkage too?? (edit: now that I think of it, of course it does. To show the camera video. Duh) So that's something to also be aware of. 😶

@sz3
Copy link
Owner

sz3 commented Jan 1, 2024

Looks like a minor fix (pinning cmake) might be necessary for the script to work as described above: #85

I'll merge that into master momentarily. (edit: done)

@Anonymous3-a
Copy link
Author

Anonymous3-a commented Jan 2, 2024

Ok, I think I got it to compile with opencv 4.9.0 and non-ancient glibc(?). I'm still in the livecd, so I'll just test it by rebooting.
Also, side note, for ldd cimbar I got:

        linux-vdso.so.1 (0x00007ffebb4f1000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8a7116d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8a70f44000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8a73816000)

So that seems to be better (more static linking)?

@Anonymous3-a
Copy link
Author

Anonymous3-a commented Jan 2, 2024

It works, and builds statically (so if you want, 4.9.0 opencv will work, but the rest of the script might need some tweaking to run without docker, which is what I want). If you want, I should be able to get the script to work outside of docker.

Update: So, cimbar buids statically, but as you said, cimbar_send and cimbar_recv still need libglfw3. I am trying to find a way to statically link it.

Update 2: I have built glfw from source, and installed the static lib. I also built it all wrong, so now I'm restarting it (hey, at least there's progress).

Update 3: It's building, but keeps linking the shared library. I'm going to take a break for a bit.

Update 4: I've decided to edit the code, so hopefully that will work.

@sz3
Copy link
Owner

sz3 commented Jan 3, 2024

It works, and builds statically (so if you want, 4.9.0 opencv will work, but the rest of the script might need some tweaking to run without docker, which is what I want). If you want, I should be able to get the script to work outside of docker.

Great! I'm interested to know how it turns out.

I don't have a problem modifying that script a bit, though the docker build will probably remain the priority (so I'd want to limit complexity). Similarly for the static build -- the priority for libcimbar as a whole is basically (1) local testing, (2) android buld, (3) wasm build, in some order. Statically linking would be a further down the list, but I also don't see a reason to not support it. 🙂

GLFW itself should be workable to static link, but IIRC there are other problems (which you may be in the middle of ...) around libGL when static linking that scared me away. (edit: but I think I was also approaching it from a musl-c perspective, and it was a few years ago... so how much do I remember correctly? 🤔 )

Looks like this is the branch from back when I was messing with it:
https://github.com/sz3/libcimbar/tree/glew-experiments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants