{"id":362,"date":"2022-08-30T15:00:05","date_gmt":"2022-08-30T15:00:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/06\/building-opencv-with-java-support-on-mac-os-x-64-bit-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:00:05","modified_gmt":"2022-08-30T15:00:05","slug":"building-opencv-with-java-support-on-mac-os-x-64-bit-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/building-opencv-with-java-support-on-mac-os-x-64-bit-collection-of-common-programming-errors\/","title":{"rendered":"Building OpenCV with Java Support on Mac OS X (64-bit)-Collection of common programming errors"},"content":{"rendered":"<p>I had literally the exact same problem! With some digging, I found that the linker ld has different flags in Unix and OS X. Thus the error:<\/p>\n<pre><code>ld: unknown option: -whole-archive\n<\/code><\/pre>\n<p>To fix, you can edit the file <code>modules\/java\/CMakeLists.txt<\/code> to use the OS X flags. (search for <code>-whole-archive<\/code>)<\/p>\n<p>Original:<\/p>\n<pre><code>target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive ${__extradeps} ${OPENCV_LINKER_LIBS})\n<\/code><\/pre>\n<p>New:<\/p>\n<pre><code>foreach(_dep ${__deps})\n  target_link_libraries(${the_module} -Wl,-force_load \"${_dep}\")\nendforeach()\n<\/code><\/pre>\n<p>I&#8217;m going to see if I can get these changes into the repo. \ud83d\ude42<\/p>\n<p><strong>&#8211;Edit&#8211;<\/strong><br \/>\nMy original answer was slightly wrong (but partly right!); I&#8217;ve changed the answer above. -force_load only works for one archive, thus the foreach. As well, it should go to the linker, thus the -Wl. See pull request 741 for details and git pull for up-to-date code.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-06 03:16:43. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I had literally the exact same problem! With some digging, I found that the linker ld has different flags in Unix and OS X. Thus the error: ld: unknown option: -whole-archive To fix, you can edit the file modules\/java\/CMakeLists.txt to use the OS X flags. (search for -whole-archive) Original: target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive ${__extradeps} ${OPENCV_LINKER_LIBS}) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-362","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=362"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/362\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}