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

Build shared lib with CMake #289

Closed
3 tasks
inkydragon opened this issue Jan 10, 2024 · 0 comments · Fixed by #291
Closed
3 tasks

Build shared lib with CMake #289

inkydragon opened this issue Jan 10, 2024 · 0 comments · Fixed by #291

Comments

@inkydragon
Copy link
Member

inkydragon commented Jan 10, 2024

  • build shared lib
  • build both static and shared lib
  • add CI
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4da8046..7a4ee75 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@ project(openlibm
         VERSION 0.8.0
         LANGUAGES C ASM)
 
-add_library("${PROJECT_NAME}" STATIC)
+add_library("${PROJECT_NAME}" SHARED)

It compiles fine, but there are errors when linking.

cmake build log
[100%] Linking C shared library libopenlibm.so
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_remainder.S.o: in function `remainder':
(.text+0x0): multiple definition of `remainder'; CMakeFiles/openlibm.dir/src/e_remainder.c.o:e_remainder.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_remainderf.S.o: in function `remainderf':
(.text+0x0): multiple definition of `remainderf'; CMakeFiles/openlibm.dir/src/e_remainderf.c.o:e_remainderf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_remainderl.S.o: in function `remainderl':
(.text+0x0): multiple definition of `remainderl'; CMakeFiles/openlibm.dir/src/e_remainderl.c.o:e_remainderl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_sqrt.S.o: in function `sqrt':
(.text+0x0): multiple definition of `sqrt'; CMakeFiles/openlibm.dir/src/e_sqrt.c.o:e_sqrt.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_sqrtf.S.o: in function `sqrtf':
(.text+0x0): multiple definition of `sqrtf'; CMakeFiles/openlibm.dir/src/e_sqrtf.c.o:e_sqrtf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_sqrtl.S.o: in function `sqrtl':
(.text+0x0): multiple definition of `sqrtl'; CMakeFiles/openlibm.dir/src/e_sqrtl.c.o:e_sqrtl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_llrint.S.o: in function `llrint':
(.text+0x0): multiple definition of `llrint'; CMakeFiles/openlibm.dir/src/s_llrint.c.o:s_llrint.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_llrintf.S.o: in function `llrintf':
(.text+0x0): multiple definition of `llrintf'; CMakeFiles/openlibm.dir/src/s_llrintf.c.o:s_llrintf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_llrintl.S.o: in function `llrintl':
(.text+0x0): multiple definition of `llrintl'; CMakeFiles/openlibm.dir/src/s_llrintl.c.o:s_llrintl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_logbl.S.o: in function `logbl':
(.text+0x0): multiple definition of `logbl'; CMakeFiles/openlibm.dir/src/s_logbl.c.o:s_logbl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_lrint.S.o: in function `lrint':
(.text+0x0): multiple definition of `lrint'; CMakeFiles/openlibm.dir/src/s_lrint.c.o:s_lrint.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_lrintf.S.o: in function `lrintf':
(.text+0x0): multiple definition of `lrintf'; CMakeFiles/openlibm.dir/src/s_lrintf.c.o:s_lrintf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_lrintl.S.o: in function `lrintl':
(.text+0x0): multiple definition of `lrintl'; CMakeFiles/openlibm.dir/src/s_lrintl.c.o:s_lrintl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_remquo.S.o: in function `remquo':
(.text+0x0): multiple definition of `remquo'; CMakeFiles/openlibm.dir/src/s_remquo.c.o:s_remquo.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_remquof.S.o: in function `remquof':
(.text+0x0): multiple definition of `remquof'; CMakeFiles/openlibm.dir/src/s_remquof.c.o:s_remquof.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_remquol.S.o: in function `remquol':
(.text+0x0): multiple definition of `remquol'; CMakeFiles/openlibm.dir/src/s_remquol.c.o:s_remquol.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_rintl.S.o: in function `rintl':
(.text+0x0): multiple definition of `rintl'; CMakeFiles/openlibm.dir/src/s_rintl.c.o:s_rintl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_scalbn.S.o: in function `scalbn':
(.text+0x0): multiple definition of `scalbn'; CMakeFiles/openlibm.dir/src/s_scalbn.c.o:s_scalbn.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_scalbn.S.o: in function `scalbn':
(.text+0x0): multiple definition of `ldexp'; CMakeFiles/openlibm.dir/src/s_scalbn.c.o:s_scalbn.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_scalbnf.S.o: in function `scalbnf':
(.text+0x0): multiple definition of `scalbnf'; CMakeFiles/openlibm.dir/src/s_scalbnf.c.o:s_scalbnf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_scalbnf.S.o: in function `scalbnf':
(.text+0x0): multiple definition of `ldexpf'; CMakeFiles/openlibm.dir/src/s_scalbnf.c.o:s_scalbnf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_scalbnl.S.o: in function `scalbnl':
(.text+0x0): multiple definition of `scalbnl'; CMakeFiles/openlibm.dir/src/s_scalbnl.c.o:s_scalbnl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/s_scalbnl.S.o: in function `scalbnl':
(.text+0x0): multiple definition of `ldexpl'; CMakeFiles/openlibm.dir/src/s_scalbnl.c.o:s_scalbnl.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_fmod.S.o: in function `fmod':
(.text+0x0): multiple definition of `fmod'; CMakeFiles/openlibm.dir/src/e_fmod.c.o:e_fmod.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_fmodf.S.o: in function `fmodf':
(.text+0x0): multiple definition of `fmodf'; CMakeFiles/openlibm.dir/src/e_fmodf.c.o:e_fmodf.c:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/openlibm.dir/amd64/e_fmodl.S.o: in function `fmodl':
(.text+0x0): multiple definition of `fmodl'; CMakeFiles/openlibm.dir/src/e_fmodl.c.o:e_fmodl.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/openlibm.dir/build.make:4522: libopenlibm.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/openlibm.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

Maybe we don't need the generic C implementation in src/ when there is a native assembly implementation for the corresponding architecture.

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

Successfully merging a pull request may close this issue.

1 participant