{"action":"opened","issue":{"url":"https://api.github.com/repos/mshabunin/test2/issues/119","labels_url":"https://api.github.com/repos/mshabunin/test2/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/mshabunin/test2/issues/119/comments","events_url":"https://api.github.com/repos/mshabunin/test2/issues/119/events","html_url":"https://github.com/mshabunin/test2/issues/119","id":96584301,"number":119,"title":"pkg-config is broken in OpenCV-2.4.0","user":{"login":"opencv-pushbot","id":2051563,"avatar_url":"https://avatars.githubusercontent.com/u/2051563?v=3","gravatar_id":"","url":"https://api.github.com/users/opencv-pushbot","html_url":"https://github.com/opencv-pushbot","followers_url":"https://api.github.com/users/opencv-pushbot/followers","following_url":"https://api.github.com/users/opencv-pushbot/following{/other_user}","gists_url":"https://api.github.com/users/opencv-pushbot/gists{/gist_id}","starred_url":"https://api.github.com/users/opencv-pushbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencv-pushbot/subscriptions","organizations_url":"https://api.github.com/users/opencv-pushbot/orgs","repos_url":"https://api.github.com/users/opencv-pushbot/repos","events_url":"https://api.github.com/users/opencv-pushbot/events{/privacy}","received_events_url":"https://api.github.com/users/opencv-pushbot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mshabunin/test2/labels/affected:%202.4","name":"affected: 2.4","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/auto-transferred","name":"auto-transferred","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/category:%20build/install","name":"category: build/install","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/priority:%20normal","name":"priority: normal","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-22T14:39:10Z","updated_at":"2015-07-22T14:39:10Z","closed_at":null,"body":"Transferred from http://code.opencv.org/issues/1925\r\n```\n|| Hiromasa YOSHIMOTO on 2012-05-12 09:24\n|| Priority: Normal\n|| Affected: 2.4.0 - 2.4.8\n|| Category: build/install\n|| Tracker: Bug\n|| Difficulty: \n|| PR: \n|| Platform: Any / Linux\n```\n\npkg-config is broken in OpenCV-2.4.0\n-----------\n```\nOpenCV-2.4.0 has a regression bug in pkg-config support.\r\n\r\nThe following pkg-config commands return wrong information now.\r\n- \"pkg-config opencv --libs\"\r\n  It returns just filename list of libraries. It must use \"-L\" and \"-l\" linker flags.\r\n- \"pkg-config opencv --libs-only-L\"\r\n- \"pkg-config opencv --libs-only-l\"\r\n  no output returned.\r\n\r\nI wrote a patch to fix this issue. Please find the attachment.\n```\n\nHistory\n-------\n##### Andrey Kamaev on 2012-05-12 12:18\n```\nThanks for the patch but it introduces another regression - versioned opencv-2.4.0.pc becomes completely broken.\r\n\r\nCould you point to any pkg-config documentation saying that it *must* use \"-L\" and \"-l\" linker flags?\n-   Target version deleted (2.4.1)\n-   Assignee changed from Alexander Shishkov to Andrey Kamaev\n```\n##### Hordur Johannsson on 2012-05-12 15:30\n```\nI looked at the pkg-config website (http://people.freedesktop.org/~dbn/pkg-config-guide.html) and they say that Libs: should contain the linker flags.\r\nIn the case of gcc the full shared library paths work, e.g\r\n \r\n  gcc myapp.cpp -o myapp `pkg-config opencv --libs`\r\n\r\nworks fine when compiling with gcc, now I'm not sure if that would break with other compilers.\r\n\r\nI most often use cmake for my build system. Then I can use the FindPkgConfig to find OpenCV,\r\nit will set OpenCV_LDFLAGS to the shared libraries. Here is in example how you might use that.\r\n\r\n  find_package(PkgConfig REQUIRED)\r\npkg_check_modules(OpenCV opencv)\r\ninclude_directories(${OpenCV_INCLUDE_DIRS})  \r\nadd_executable(myapp myapp.cpp)\r\ntarget_link_libraries(myapp ${OpenCV_LDFLAGS})\n```\n##### Hiromasa YOSHIMOTO on 2012-05-13 07:10\n```\nThanks for your comments. I'll fix my patch later.\r\n\r\nI mean that the \"linker flags\" *should* use -L and -l flags.\r\n\r\nI could not find any explicit specification, but\r\npkg-config seems to expect -L and -l in linker flags.\r\nBecause it provides the following two options(*1,*2);\r\n* --libs-only-L for printing -L/-R part of \"--libs\"\r\n* --libs-only-l for printing -l part of \"--libs\"\r\n\r\nAnyway, the issue is opencv.pc has been changed in OpenCV-2.4\r\nand it breaks backword compatibility. Is there any reason to break it?\r\n\r\n\r\n*1) see man page of pkg-config or http://linux.die.net/man/1/pkg-config \r\n*2) Please search pkg-config and \"--libs-only-L\" on Internet.\r\nYou will find how these options are used in makefile/autotools/cmake files.\n```\n##### Hiromasa YOSHIMOTO on 2012-05-14 10:45\n```\nWhen I checked versioned opencv-2.4.0.pc, \r\nI found another issue in shared library versioning.\r\nSee #1928 for details.\r\n\r\nI'd like to update my patch when #1928 is closed\r\nbecause this pkg-config issue depends on #1928.\n```\n##### Peter Housel on 2012-08-28 17:57\n```\nAn important reason to use -L is that in cross-compilation environments, pkg-config will prefix -L and -I paths with the path found in PKG_CONFIG_SYSROOT_DIR. This variable normally points to a target sysroot directory containing include files, libraries, and pkgconfig files for the cross-compilation target.\n```\n##### Andrey Kamaev on 2012-10-22 08:48\n```\n-   Assignee deleted (Andrey Kamaev)\n```\n##### Ray Rashif on 2012-11-05 17:17\n```\nThis is still broken in 2.4.3, and it breaks standard pkg-config usage. Another patch attached which makes use of CMake's functionality instead of string replacement.\n-   File pkgconfig.patch added\n```\n##### Sebastian Krämer on 2012-11-14 17:03\n```\nI'm having the same issues with pkg-config on 64 bit linux. I tried your patch but it doesn't solve the issues for me (although the situation has improved a bit):\r\n<pre>$ PKG_CONFIG_PATH=\"`pwd`\" pkg-config --libs opencv\r\nliblibpng /usr/lib64/libQtTest.so /usr/lib64/libQtCore.so /usr/lib64/libQtGui.so /usr/lib64/libQtOpenGL.so /lib64/libXext.so /lib64/libX11.so /lib64/libICE.so /lib64/libSM.so /lib64/libGL.so /lib64/libGLU.so rt pthread m dl stdc++ /lib64/libz.so -L/home/sebi/src/opencv/lib -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_core\r\n</pre>\r\nAt least the opencv _-l_ parameters are there now.\r\nNotice the _liblibpng_ at the beginning.\n```\n##### Vadim Pisarevsky on 2014-11-15 09:21\n```\nThere have been some PR's fixing problems with pkg-config. Hopefully, the problem has been solved.\n-   Affected version set to 2.4.0 - 2.4.8\n-   Operating System set to Linux\n-   HW Platform set to Any\n-   Status changed from Open to Done\n```\n##### Timocheck Jackson on 2015-02-17 19:53\n```\nThe problem is still seems to be present with version 2.4.10:\r\n\r\n# pkg-config opencv --libs-only-l\r\n-lrt -lpthread -lm -ldl  \r\n# pkg-config opencv --libs-only-L\r\n \r\n# \r\n\r\nStill no \"-L\" flags. Not possible to link opencv with other programs.\n-   Assignee set to Hiromasa YOSHIMOTO\n-   Status changed from Done to Incomplete\n```\n##### Steven Puttemans on 2015-02-19 09:11\n```\n@Timo\r\n\r\nIs it possible that you are using the wrong pkg-config command? I have been using the command for ages on my Ubuntu system with 2.4.10 and it works perfectly.\r\nMy command:\r\n<pre>\r\n`pkg-config opencv --libs`\r\n</pre>\n```"}}