amule-project / amule

'All-platform' P2P client based on eMule
1.01k stars 221 forks source link

2.3.3 build fails with cmake on openSUSE #269

Closed lgbaldoni closed 3 years ago

lgbaldoni commented 3 years ago

I think the problem is different from the one described in https://github.com/amule-project/amule/issues/261.

First of all, autotools builds correctly using the same dependencies. I have a build failure due to a seemingly badly passed definition to the compiler on openSUSE Tumbleweed (the rolling release):

[ 21%] Building C object src/utils/cas/CMakeFiles/cas.dir/cas.c.o
cd /home/abuild/rpmbuild/BUILD/amule-2.3.3/build/src/utils/cas && /usr/bin/cc -D-I/usr/include/freetype2 -D-I/usr/include/libpng16 -D-I/usr/include/uuid -DAVIF_DLL __GD__ -I/home/abuild/rpmbuild/BUILD/amule-2.3.3/build -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -DNDEBUG -O2 -g -DNDEBUG -o CMakeFiles/cas.dir/cas.c.o -c /home/abuild/rpmbuild/BUILD/amule-2.3.3/src/utils/cas/cas.c
cc: error: __GD__: No such file or directory
make[2]: *** [src/utils/cas/CMakeFiles/cas.dir/build.make:85: src/utils/cas/CMakeFiles/cas.dir/cas.c.o] Error 1

And a linking error at the end with openSUSE Leap (the stable release), partial snippet:

[ 80%] Linking CXX executable amuled
cd /home/abuild/rpmbuild/BUILD/amule-2.3.3/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/amuled.dir/link.txt --verbose=1
/usr/bin/c++  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DNDEBUG -O2 -g -DNDEBUG   -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now CMakeFiles/amuled.dir/kademlia/kademlia/Kademlia.cpp.o CMakeFiles/amuled.dir/kademlia/kademlia/Prefs.cpp.o CMakeFiles/amuled.dir/kademlia/kademlia/Search.cpp.o CMakeFiles/amuled.dir/kademlia/kademlia/UDPFirewallTester.cpp.o CMakeFiles/amuled.dir/kademlia/net/KademliaUDPListener.cpp.o CMakeFiles/amuled.dir/kademlia/net/PacketTracking.cpp.o CMakeFiles/amuled.dir/kademlia/routing/Contact.cpp.o CMakeFiles/amuled.dir/kademlia/routing/RoutingZone.cpp.o CMakeFiles/amuled.dir/amule.cpp.o CMakeFiles/amuled.dir/BaseClient.cpp.o CMakeFiles/amuled.dir/ClientCreditsList.cpp.o CMakeFiles/amuled.dir/ClientList.cpp.o CMakeFiles/amuled.dir/ClientTCPSocket.cpp.o CMakeFiles/amuled.dir/ClientUDPSocket.cpp.o CMakeFiles/amuled.dir/CorruptionBlackBox.cpp.o CMakeFiles/amuled.dir/DownloadClient.cpp.o CMakeFiles/amuled.dir/DownloadQueue.cpp.o CMakeFiles/amuled.dir/ECSpecialCoreTags.cpp.o CMakeFiles/amuled.dir/EMSocket.cpp.o CMakeFiles/amuled.dir/EncryptedStreamSocket.cpp.o CMakeFiles/amuled.dir/EncryptedDatagramSocket.cpp.o CMakeFiles/amuled.dir/ExternalConn.cpp.o CMakeFiles/amuled.dir/FriendList.cpp.o CMakeFiles/amuled.dir/IPFilter.cpp.o CMakeFiles/amuled.dir/KnownFileList.cpp.o CMakeFiles/amuled.dir/ListenSocket.cpp.o CMakeFiles/amuled.dir/MuleUDPSocket.cpp.o CMakeFiles/amuled.dir/SearchFile.cpp.o CMakeFiles/amuled.dir/SearchList.cpp.o CMakeFiles/amuled.dir/ServerConnect.cpp.o CMakeFiles/amuled.dir/ServerList.cpp.o CMakeFiles/amuled.dir/ServerSocket.cpp.o CMakeFiles/amuled.dir/ServerUDPSocket.cpp.o CMakeFiles/amuled.dir/SHAHashSet.cpp.o CMakeFiles/amuled.dir/SharedFileList.cpp.o CMakeFiles/amuled.dir/UploadBandwidthThrottler.cpp.o CMakeFiles/amuled.dir/UploadClient.cpp.o CMakeFiles/amuled.dir/UploadQueue.cpp.o CMakeFiles/amuled.dir/ThreadTasks.cpp.o CMakeFiles/amuled.dir/amuleAppCommon.cpp.o CMakeFiles/amuled.dir/ClientRef.cpp.o CMakeFiles/amuled.dir/ECSpecialMuleTags.cpp.o CMakeFiles/amuled.dir/GetTickCount.cpp.o CMakeFiles/amuled.dir/GuiEvents.cpp.o CMakeFiles/amuled.dir/HTTPDownload.cpp.o CMakeFiles/amuled.dir/KnownFile.cpp.o CMakeFiles/amuled.dir/Logger.cpp.o CMakeFiles/amuled.dir/PartFile.cpp.o CMakeFiles/amuled.dir/Preferences.cpp.o CMakeFiles/amuled.dir/Proxy.cpp.o CMakeFiles/amuled.dir/Server.cpp.o CMakeFiles/amuled.dir/Statistics.cpp.o CMakeFiles/amuled.dir/StatTree.cpp.o CMakeFiles/amuled.dir/UserEvents.cpp.o CMakeFiles/amuled.dir/amuled.cpp.o  -o amuled  libs/ec/cpp/libec.a libmuleappcommon.a libmuleappcore.a libs/common/libmulecommon.a libmulesocket.a /usr/lib64/libwx_baseu_net-3.0.so /usr/lib64/libz.so /usr/lib64/libupnp.so -lupnp -lthreadutil -lixml /usr/lib64/libcryptopp.so /usr/lib64/libwx_baseu-3.0.so 
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: libmuleappcore.a(ThreadScheduler.cpp.o): warning: relocation against `wxTheAssertHandler' in read-only section `.text'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: libmuleappcommon.a(UPnPBase.cpp.o): in function `wxString::SubstrBufFromType<wchar_t const*>::SubstrBufFromType(wchar_t const* const&, unsigned long)':
/usr/include/wx-3.0/wx/string.h:433: undefined reference to `wxTheAssertHandler'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /usr/include/wx-3.0/wx/string.h:433: undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'

Full build logs here.

sisco0 commented 3 years ago

I reached a solution on completing a build under OpenSUSE Tumbleweed DockerHub container, which uses CMake and latest wxWidgets:

Short way, using CMake

xhost +local:root
docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix opensuse/tumbleweed bash

# Install needed dependencies
zypper install git-core cmake gcc-c++ zlib-devel libcryptopp-devel \
  glibc-locale wxWidgets-3_2-devel xorg-x11-fonts-core xorg-x11-fonts

mkdir app; cd app

# Create a folder and clone amule
git clone https://github.com/amule-project/amule.git
# Go into amule folder and build 
cd amule
cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build -j`nproc`
cmake --install build

/usr/local/bin/amule

Long way, without using CMake and using custom wxWidgets version

Another solution would not use CMake and would install the proposed wxWidgets version:

xhost +local:root
docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix opensuse/tumbleweed bash

# Install needed dependencies
zypper install git-core cmake gcc-c++ zlib-devel libcryptopp-devel autoconf \
  automake libtool diffutils libupnp-devel wget glibc-locale wxGTK-devel \
  xorg-x11-fonts-core xorg-x11-fonts

mkdir app; cd app

# Clone GeoIP
git clone https://github.com/maxmind/geoip-api-c.git
cd geoip-api-c
# Build GeoIP
./bootstrap
./configure
make -j`nproc`
make install
cd ..

# Download wxGTK 2.8
wget https://github.com/wxWidgets/wxWidgets/releases/download/v2.8.12/wxGTK-2.8.12.tar.gz
tar xvzf wxGTK-2.8.12.tar.gz
cd wxGTK-2.8.12/
export CFLAGS=-std=c99 CXXFLAGS=-std=c++98
./configure --prefix=/usr --with-gtk --enable-unicode --disable-compat24 --enable-optimise
make -j`nproc`
make install
ldconfig
cd ..

# Create a folder and clone amule
git clone https://github.com/amule-project/amule.git
# Go into amule folder and build 
cd amule
./autogen.sh
./configure --disable-debug --enable-geoip --enable-optimize --with-wxversion=2.8.12
make -j`nproc`
make install

/usr/local/bin/amule

Comments on the solutions

  1. If you are not using Docker please ignore the xhost and docker lines above.
  2. Take care of using sudo if you are not root for the needed commands.
Vollstrecker commented 3 years ago

Not really. We have 2 problems here:

First:

-DAVIF_DLL __GD__

There is just a -D missing. Or more precise, AVIF_DLL is too much, and occupies the -D of GD. You just don't catch this, as you don't enable cas, so it can't fail.

Second:

undefined reference to `wxTheAssertHandler'

As wx-detection is just in rewriting process, it no surprise that it fails. Plus you are using wx-3.2 with cmake and 2.8 with autotools. Hopefully my fix will also detect what has change for usage with 3.2.

Btw. is it really a solution to run it in docker or mix system and selfcompiled libs with all the hustle of keeping all LD_PATH and stuff clean for the system at all? I mean, if you would suggest static linking, it would work, but this solution has so much potential to mess the system of unexperienced users, that I would call it negligent sabotage.

lgbaldoni commented 3 years ago

First:

-DAVIF_DLL __GD__

There is just a -D missing. Or more precise, AVIF_DLL is too much, and occupies the -D of GD. You just don't catch this, as you don't enable cas, so it can't fail.

Sorry, I'm passing -DBUILD_CAS=ON to cmake. Are you saying I shouldn't?

Or just add the -D here ?

Second:

undefined reference to `wxTheAssertHandler'

As wx-detection is just in rewriting process, it no surprise that it fails. Plus you are using wx-3.2 with cmake and 2.8 with autotools. Hopefully my fix will also detect what has change for usage with 3.2.

I'm pretty sure I'm using 3.0 for both autotools and cmake. The log shows cmake detecting it as 3.0.5 and wx-config --version as 3.0.3, but I believe that's the only inconsistency.

Btw. is it really a solution to run it in docker or mix system and selfcompiled libs

Docker or static libs is not acceptable for inclusion as rpm package. At least on OBS.

Vollstrecker commented 3 years ago

Sorry, I'm passing -DBUILD_CAS=ON to cmake. Are you saying I shouldn't?

Nope, if you want cas you surely should, sisco didn't, so he can't compare.

I'm pretty sure I'm using 3.0 for both autotools and cmake

Again this wasn't meant as answer to you post. Your catch is correct, and the fix will come.

Btw. is it really a solution to run it in docker or mix system and selfcompiled libs

Docker or static libs is not acceptable for inclusion as rpm package. At least on OBS.

I know, just wanted to make sure everyone get's that. docker/flat/snap is the new fancy thing that enables users to adjust their system to satisfy a broken pieces needs. Does it work? Sure. Is his a solution? Hell no.

sisco0 commented 3 years ago

Hello @lgbaldoni , as stated in the comments on the solution part, using Docker is not needed, just remove the Docker lines. I had to use Docker just for testing purposes that the solution works under a simulated OpenSuse environment as I currently use Ubuntu 😀.