rockowitz / ddcui

Graphical user interface for ddcutil - control monitor settings
http://www.ddcutil.com
GNU General Public License v2.0
147 stars 2 forks source link

Library path from pkg-config ignored in cmake build #4

Open VorpalBlade opened 5 years ago

VorpalBlade commented 5 years ago

If ddcutil is installed in a directory that is not in the standard library path (e.g. somewhere in /opt like I did it), you will get an error like the following:

[  5%] Linking CXX executable ddcui
/usr/bin/ld: cannot find -lddcutil
/usr/bin/ld: cannot find -lddcutil

To fix this, DDCUTIL_LIBRARY_DIRS must be used I would assume (see https://cmake.org/cmake/help/v3.1/module/FindPkgConfig.html) but I'm not sure where.

rockowitz commented 5 years ago

On 09/17/2018 03:42 PM, Arvid Norlander wrote:

If ddcutil is installed in a directory that is not in the standard library path (e.g. somewhere in /opt like I did it), you will get an error like the following:

|[ 5%] Linking CXX executable ddcui /usr/bin/ld: cannot find -lddcutil /usr/bin/ld: cannot find -lddcutil |

To fix this, DDCUTIL_LIBRARY_DIRS must be used I would assume (see https://cmake.org/cmake/help/v3.1/module/FindPkgConfig.html) but I'm not sure where.

Perhaps.  What is the output of "pkg-config ddcutil --variable=libdir" on your system?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rockowitz/ddcui/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ANhsbg506_QdMDhY2--DB_En7OyOLqP5ks5ub_s3gaJpZM4WslOV.

VorpalBlade commented 5 years ago

Assuming I first export the proper PKG_CONFIG_PATH (which I did):

$ pkg-config ddcutil --variable=libdir
/opt/ddcutil/lib
rockowitz commented 5 years ago

I've added a link_directories(#DDCUTIL_LIBRARY_DIRS) statement to CMakeLists.txt.   Not sure if this is the best solution - I'm new to CMake.  The change has been pushed on branch 0.0.3.   Let me know if this works for you.

Sanford

On 09/18/2018 01:02 AM, Arvid Norlander wrote:

Assuming I first export the proper PKG_CONFIG_PATH (which I did):

|$ pkg-config ddcutil --variable=libdir /opt/ddcutil/lib |

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rockowitz/ddcui/issues/4#issuecomment-422256055, or mute the thread https://github.com/notifications/unsubscribe-auth/ANhsbkL0HgGaeWRj3-5C4V7V_CNxzsuXks5ucH54gaJpZM4WslOV.

VorpalBlade commented 5 years ago

This does not appear to work (even after changing to ${} instead of plain $, which i believe is required in cmake).

I'm not used to pkg-config, and all the non-pkg-config library finding support that I have used in cmake have always returned absolute paths. Not sure how this is supposed to work. I messed around with it a bit but didn't get anywhere (except manually adding -L/opt/ddcutil/lib to my linker flags, which is not a good solution).

VorpalBlade commented 5 years ago

Aha, figured it out: link_directories() (with ${} syntax) must go before add_executable().

rockowitz commented 5 years ago

Thank you.  I had misinterpreted the line "The command will apply only to targets created after it is called." in the link_directories() documentation.

On 09/18/2018 04:26 AM, Arvid Norlander wrote:

Aha, figured it out: link_directories() (with ${} syntax) must go before add_executable().

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rockowitz/ddcui/issues/4#issuecomment-422303038, or mute the thread https://github.com/notifications/unsubscribe-auth/ANhsblVm66NL4cqmkM1Z1GriVnNc4lXzks5ucK4agaJpZM4WslOV.

rockowitz commented 4 years ago

CMakeLists.txt and ddcui.pro have been reworked in release 0.0.6. Also, I added a page discussing how to handle files include files, libraries, and pkg-config files that are not in their production locations.