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

Linker error when compiling latest master #193

Open
lnjX opened this issue Mar 2, 2021 · 5 comments
Open

Linker error when compiling latest master #193

lnjX opened this issue Mar 2, 2021 · 5 comments

Comments

@lnjX
Copy link

lnjX commented Mar 2, 2021

Hello, I'm running on debian unstable and I've just tried to build ympd master. Unfortunately I got the following linker error:

Scanning dependencies of target mkdata
[ 10%] Building C object CMakeFiles/mkdata.dir/tools/mkdata.c.o
[ 20%] Linking C executable mkdata
[ 20%] Built target mkdata
[ 30%] Generating assets.c
Scanning dependencies of target ympd
[ 40%] Building C object CMakeFiles/ympd.dir/src/ympd.c.o
[ 50%] Building C object CMakeFiles/ympd.dir/src/mpd_client.c.o
[ 60%] Building C object CMakeFiles/ympd.dir/src/mongoose.c.o
[ 70%] Building C object CMakeFiles/ympd.dir/src/json_encode.c.o
[ 80%] Building C object CMakeFiles/ympd.dir/src/http_server.c.o
[ 90%] Building C object CMakeFiles/ympd.dir/assets.c.o
[100%] Linking C executable ympd
/usr/bin/ld: CMakeFiles/ympd.dir/src/mpd_client.c.o:(.bss+0x0): multiple definition of `mpd'; CMakeFiles/ympd.dir/src/ympd.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/ympd.dir/src/mpd_client.c.o:(.bss+0x190b0): multiple definition of `dirble_api_token'; CMakeFiles/ympd.dir/src/ympd.c.o:(.bss+0x190b0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ympd.dir/build.make:205: ympd] Error 1
make[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/ympd.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
@SuperBFG7
Copy link
Contributor

possible duplicate of #190

@spendist
Copy link

same as me

@unera
Copy link

unera commented Mar 25, 2024

Hi, there

Today i tried to build ympd, too.
I have the same log at master:

$ LANG=C git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ git describe     
v1.0.1-170-g612f8fc
$ LANG=C cmake ..  -DCMAKE_INSTALL_PREFIX:PATH=/usr
-- The C compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Found LibMPDClient: /usr/lib/x86_64-linux-gnu/libmpdclient.so  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1k")  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/unera/work/ympd/build


$ LANG=C make                                      
Scanning dependencies of target mkdata
[ 10%] Building C object CMakeFiles/mkdata.dir/tools/mkdata.c.o
[ 20%] Linking C executable mkdata
[ 20%] Built target mkdata
[ 30%] Generating assets.c
Scanning dependencies of target ympd
[ 40%] Building C object CMakeFiles/ympd.dir/src/ympd.c.o
[ 50%] Building C object CMakeFiles/ympd.dir/src/mpd_client.c.o
[ 60%] Building C object CMakeFiles/ympd.dir/src/mongoose.c.o
[ 70%] Building C object CMakeFiles/ympd.dir/src/json_encode.c.o
[ 80%] Building C object CMakeFiles/ympd.dir/src/http_server.c.o
[ 90%] Building C object CMakeFiles/ympd.dir/assets.c.o
[100%] Linking C executable ympd
/usr/bin/ld: CMakeFiles/ympd.dir/src/mpd_client.c.o:(.bss+0x0): multiple definition of `mpd'; CMakeFiles/ympd.dir/src/ympd.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/ympd.dir/src/mpd_client.c.o:(.bss+0x190b0): multiple definition of `dirble_api_token'; CMakeFiles/ympd.dir/src/ympd.c.o:(.bss+0x190b0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ympd.dir/build.make:205: ympd] Error 1
make[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/ympd.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

@unera
Copy link

unera commented Mar 25, 2024

I've just patched something and it is building fine for me

diff --git a/src/mpd_client.h b/src/mpd_client.h
index 447dd56..9fc55eb 100644
--- a/src/mpd_client.h
+++ b/src/mpd_client.h
@@ -96,9 +96,11 @@ struct t_mpd {
 
     int song_id;
     unsigned queue_version;
-} mpd;
+};
+
+extern struct t_mpd mpd;
 
-char dirble_api_token[28];
+extern char dirble_api_token[];
 
 struct t_mpd_client_session {
     int song_id;
diff --git a/src/ympd.c b/src/ympd.c
index 3aed7e6..2e23746 100644
--- a/src/ympd.c
+++ b/src/ympd.c
@@ -29,6 +29,8 @@
 #include "mpd_client.h"
 #include "config.h"
 
+char dirble_api_token[28];
+struct t_mpd mpd;
 extern char *optarg;
 
 int force_exit = 0;

@spendist
Copy link

Professional answers. Thank you so much.
cd ~/src/ympd, vim ympd.patch, and insert text above, run patch -p1<ympd.patch, ok, try again.. pass

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

4 participants