baconpaul / elastika_plugin

GNU General Public License v3.0
2 stars 3 forks source link

Linker error #1

Closed cosinekitty closed 1 year ago

cosinekitty commented 1 year ago

I ran into this trying to build. Any ideas? It's possible I screwed up my development system when I built gcc 12.2.0 from source. Let me know if you need more info...

don@spearmint:~/github/elastika_plugin $ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
don@spearmint:~/github/elastika_plugin $ cmake -Bbuild -DCMAKE_BUILD_TYPE=RELEASE
-- The CXX compiler identification is GNU 12.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/don/gcc12/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Elastika Plugin will require manual copy after build
-- The C compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/don/gcc12/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
-- Checking for module 'alsa'
--   Found alsa, version 1.1.8
-- Checking for module 'freetype2'
--   Found freetype2, version 22.1.16
-- Checking for module 'libcurl'
--   Found libcurl, version 7.64.0
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
--   No package 'webkit2gtk-4.0' found
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Building CLAP with CLAP_CXX_STANDARD=17
-- Creating CLAP elastika-filter_CLAP from elastika-filter
-- Setting Misbehaviour handler level to 'Ignore'
-- Setting Checking handler level to 'Minimal'
-- Setting event resolution to 32 samples
-- Setting "Always split block" to OFF
-- Setting "Use JUCE parameter ranges" to OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/don/github/elastika_plugin/build

don@spearmint:~/github/elastika_plugin $ cmake --build build --target elastika-filter_VST3
[  3%] Building CXX object libs/clap-juce-extensions/CMakeFiles/clap_juce_extensions.dir/src/extensions/clap-juce-extensions.cpp.o
[  6%] Linking CXX static library libclap_juce_extensions.a
[  6%] Built target clap_juce_extensions
[ 10%] Building CXX object CMakeFiles/elastika-dsp.dir/libs/sapphire/src/mesh_hex.cpp.o
[ 13%] Building CXX object CMakeFiles/elastika-dsp.dir/libs/sapphire/src/mesh_physics.cpp.o
[ 16%] Linking CXX static library libelastika-dsp.a
[ 16%] Built target elastika-dsp
[ 20%] Building CXX object CMakeFiles/elastika-filter.dir/src/ElastikaProcessor.cpp.o
[ 23%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_utils.cpp.o
[ 26%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_core/juce_core.cpp.o
[ 30%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_utils/juce_audio_utils.cpp.o
[ 33%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_processors/juce_audio_processors.cpp.o
[ 36%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_processors/juce_audio_processors_ara.cpp.o
[ 40%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_processors/juce_audio_processors_lv2_libs.cpp.o
[ 43%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_gui_extra/juce_gui_extra.cpp.o
[ 46%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp.o
[ 50%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_graphics/juce_graphics.cpp.o
[ 53%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_events/juce_events.cpp.o
[ 56%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_data_structures/juce_data_structures.cpp.o
[ 60%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_basics/juce_audio_basics.cpp.o
[ 63%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp.o
[ 66%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_audio_devices/juce_audio_devices.cpp.o
[ 70%] Building CXX object CMakeFiles/elastika-filter.dir/libs/JUCE/modules/juce_dsp/juce_dsp.cpp.o
[ 73%] Linking CXX static library elastika-filter_artefacts/RELEASE/libElastika_SharedCode.a
[ 73%] Built target elastika-filter
[ 76%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp.o
[ 80%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_ARA.cpp.o
[ 83%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_LV2.cpp.o
[ 86%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp.o
[ 90%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp.o
[ 93%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp.o
[ 96%] Building CXX object CMakeFiles/elastika-filter_VST3.dir/libs/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp.o
[100%] Linking CXX shared module elastika-filter_artefacts/RELEASE/VST3/Elastika.vst3/Contents/x86_64-linux/Elastika.so
/usr/bin/ld: libelastika-dsp.a(mesh_hex.cpp.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: libelastika-dsp.a(mesh_physics.cpp.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/elastika-filter_VST3.dir/build.make:198: elastika-filter_artefacts/RELEASE/VST3/Elastika.vst3/Contents/x86_64-linux/Elastika.so] Error 1
make[2]: *** [CMakeFiles/Makefile2:334: CMakeFiles/elastika-filter_VST3.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:341: CMakeFiles/elastika-filter_VST3.dir/rule] Error 2
make: *** [Makefile:222: elastika-filter_VST3] Error 2
cosinekitty commented 1 year ago

Oh, I wonder if it's because I disabled multilib support when I built gcc? I made it support 64-bit processors only.

baconpaul commented 1 year ago

no its fPIC. Hold on one second.

baconpaul commented 1 year ago

We need to add

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

to the CMakeLists.txt before the action. So probably before the project line right after the OSX version line.

baconpaul commented 1 year ago

OK over in #2 I am fixing the CMake and also put in place GitHub actions to do test builds on PRs (but still not make an installer available). Hold on - lemme merge it if linux and mac work.

cosinekitty commented 1 year ago

Looks like I need to define my own damn pi constant for Windows, LOL.

baconpaul commented 1 year ago

Nah I have that fixed too. Gimme a second.

We need to define _USE_MATH_DEFINES. Xenaikos found it yesterday and I just didn't push it yet

I'll merge in a minute when all 3 build in CI.

cosinekitty commented 1 year ago

I had to build cmake from source to get a recent enough version. I got it working on the fifth try! I also had to do some manual copying C++ runtime libraries around and ln -s to point to them. Slightly scary stuff.

baconpaul commented 1 year ago

i am really surprised you had to move runtime libraries around. what distro are you on?

baconpaul commented 1 year ago

Anyway the merge I just did means it builds on macOS-latest, windows-2019 and ubuntu 22 out of the box (although it does a few apt gets on ubuntu first). Curious which problems you ran into?

(I'm sure theres a few more settings from surge I need to copy over but it builds now at least!)

cosinekitty commented 1 year ago

I'm on Debian Bullseye. The reason is I built gcc 12.2.0 from source code, and I installed it under my home directory: /home/don/gcc12. I did this to avoid wrecking my system, so I left the installed gcc Debian package intact. Then I put /home/don/gcc12/bin at the front of my PATH. This mostly works, only it blew up when trying to build cmake. It used gcc 12 to build the code, but it tried to use the older runtime library that was still in /usr/lib/x86_64-linux-gnu. I may have to undo this later, but I hacked things by copying the new libstdc++.so.6.0.30 over there and changed the symlink libstdc++.so.6 to point to it instead of the old .25 version. Life in the fast lane...

baconpaul commented 1 year ago

Oh right. Well you should probably do CXX_COMPILER=/home/don/gcc/bin cmake -B build then but yeah if you have a system like you describe you will have to do stuff like you describe :)

baconpaul commented 1 year ago

sorry I mean

cmake -Bbuild -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER=/home/don/blahlbah

and that should find the compiler and linker from your custom.

baconpaul commented 1 year ago

(whether a daw will subsequently find the glib without a LD_LIBRARY_PATH is a separate question)

cosinekitty commented 1 year ago

OK. In 2023 I will probably buy another development system for a garage/workshop we are building. I'm thinking of trying out Arch Linux, so that I can more easily use more recent tools. Debian is nice because it's stable, but stuff gets a bit old. I have even completed a couple of Linux From Scratch builds, which was very educational, but there is no way I would want to maintain a system that way!

Anyway, your fixes worked great... I nuked the build directory, pulled, and rebuilt from the top. Everything finished fine. Thanks!

baconpaul commented 1 year ago

Great!