albfan / miraclecast

Connect external monitors to your system via Wifi-Display specification also known as Miracast
Other
3.66k stars 407 forks source link

Build error in ubuntu 22.04 #464

Closed xliang-lifesize closed 1 year ago

xliang-lifesize commented 1 year ago

There is build error in ubuntu 22.04 which caused by the newer gcc This is the patch can fix it.

diff --git a/src/dhcp/CMakeLists.txt b/src/dhcp/CMakeLists.txt
index 7ae3e30..d7f8b7b 100644
--- a/src/dhcp/CMakeLists.txt
+++ b/src/dhcp/CMakeLists.txt
@@ -13,6 +13,7 @@ add_executable(miracle-dhcp ${miracle-dhcp_SRCS})
 find_package(PkgConfig)
 pkg_check_modules (GLIB2 REQUIRED glib-2.0)
 pkg_check_modules (UDEV REQUIRED libudev)
+target_link_libraries(miracle-dhcp miracle-shared)
 link_directories( ${UDEV_LIBRARY_DIRS})
 include_directories( ${UDEV_INCLUDE_DIRS})
 target_link_libraries(miracle-dhcp ${UDEV_LIBRARIES})
@@ -21,7 +22,6 @@ link_directories( ${GLIB2_LIBRARY_DIRS})
 include_directories( ${GLIB2_INCLUDE_DIRS})
 target_link_libraries(miracle-dhcp ${GLIB2_LIBRARIES})

-target_link_libraries(miracle-dhcp miracle-shared)

 install(TARGETS miracle-dhcp DESTINATION bin)
 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared)
albfan commented 1 year ago

Build for cmake on latest commit from master:

https://albfan.semaphoreci.com/jobs/0a20a300-db7f-4777-942c-6265823d8d88

how is it possible that a change in order makes a difference?

I use this image for CI

https://hub.docker.com/layers/albfan/miraclecast-ci/latest/images/sha256-1054c0555ac2344f1322ff0a522523797c21783ebf234259ff8dda43af43e939?context=explore

probably move to github actions is a good idea, but still I need more info to make that change, seems irrelevant

xliang-lifesize commented 1 year ago

I build from my Ubuntu 22.04. GCC (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0. Here is the error(make VERBOSE=1) :

cd /home/tester/project/miraclecast/build/src/dhcp && /usr/bin/cmake -E cmake_link_script CMakeFiles/miracle-dhcp.dir/link.txt --verbose=1
/usr/bin/cc -std=gnu11 -std=gnu11  -rdynamic CMakeFiles/miracle-dhcp.dir/dhcp.c.o CMakeFiles/miracle-dhcp.dir/common.c.o CMakeFiles/miracle-dhcp.dir/ipv4ll.c.o CMakeFiles/miracle-dhcp.dir/client.c.o CMakeFiles/miracle-dhcp.dir/server.c.o -o miracle-dhcp  -ludev -lm -lglib-2.0 ../shared/libmiracle-shared.a -lsystemd
/usr/bin/ld: ../shared/libmiracle-shared.a(shl_log.c.o): undefined reference to symbol 'lrint@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/dhcp/CMakeFiles/miracle-dhcp.dir/build.make:162: src/dhcp/miracle-dhcp] Error 1
make[2]: Leaving directory '/home/tester/project/miraclecast/build'
make[1]: *** [CMakeFiles/Makefile2:309: src/dhcp/CMakeFiles/miracle-dhcp.dir/all] Error 2
make[1]: Leaving directory '/home/tester/project/miraclecast/build'
make: *** [Makefile:136: all] Error 2

From the command line, if you move the "../shared/libmiracle-shared.a" before the "-ludev", it will work.

xliang-lifesize commented 1 year ago

I am not sure why this happen. But looks like the link lib order need be correct(why??)

albfan commented 1 year ago

From this comment, looks as you mention, order is relevant for this

https://stackoverflow.com/a/34513053/848072

Let me know if you can provide a PR (to be properly credited)

SvenDowideit commented 1 year ago

this also hit me on 22.04 , and the diff above was enough to resolve it for me - @albfan or @xliang-lifesize

xliang-lifesize commented 1 year ago

Hi @albfan,

I am really sorry I missed this comment.

I tried to create a PR, but I failed with push the PR by user error. Looks like I don't have the correct user for this project. Or I didn't push it correct. Could you help to create the PR? I found the issue and have the fix. But I learned from the stackoverflow too. So, the credit should go to everyone.

Happy new year!

albfan commented 1 year ago

@xliang-lifesize we only need a name and email like the one you provide on:

git config user.name git config user.email

https://github.com/albfan/miraclecast/pull/472 should be enough, but let me know those details to properly credit you

xliang-lifesize commented 1 year ago

@xliang-lifesize we only need a name and email like the one you provide on:

git config user.name git config user.email

472 should be enough, but let me know those details to properly credit you

Hi @albfan Here is my config user.name: Xiao Qiang Liang user.email: xliang@lifesize.com

Thank you.