Here is the output from otool -L on skedmo-solver that you requested:

skedmo-solver:
    libmysqlclient.18.dylib (compatibility version 18.0.0, current version
18.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1197.1.1)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version
1.2.5)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version
120.0.0)

on /usr/lib/libmysqlclient.18.dylib I get an error
aaron-schurgers-computer-3:lib schurger$ otool -L libmysqlclient.18.dylib
error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
can't open file: libmysqlclient.18.dylib (No such file or directory)

even though the file libmysqlclient.18.dylib is clearly there when I do ls

However, when I try it on /usr/lib/libmysqlclient.dylib it works:
aaron-schurgers-computer-3:lib schurger$ otool -L libmysqlclient.dylib
libmysqlclient.dylib:
    libmysqlclient.18.dylib (compatibility version 18.0.0, current version
18.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version
65.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 169.3.0)

There is no libmysqlclient.18.dylib in /Applications/MAMP/Library/lib.

Thanks,
Aaron

On Wed, Sep 7, 2016 at 2:52 PM, <clin...@elemtech.com> wrote:

> It may help to include the output of "otool -L" on skedmo-solver,
> /usr/lib/libmysqlclient.18.dylib and /Applications/MAMP/Library/
> lib/libmysqlclient.18.dylib.
> And it may also help to see if there is a difference in the otool output
> in the Xcode vs makefile scenario.
>
> Also, it may help to check the output of "otool -l skedmo-solver" for both
> the Xcode and makefile scenario.
>
> Clint
>
> ----- On Sep 7, 2016, at 5:18 AM, Cotton Candy <cottoncandyco...@gmail.com>
> wrote:
>
> Hi Peter,
> I attach my CMakeLists.txt file as well as the FindMySQL.cmake finder that
> I used, in case these help.
>
> I still get the same error when I run the executable:
> dyld: Library not loaded: libmysqlclient.18.dylib
>   Referenced from: /Users/schurger/tmp/test_CMake2/./skedmo-solver
>   Reason: image not found
> Trace/BPT trap: 5
>
> This library (libmysqlclient.18.dylib) is in /usr/lib on my machine.
>
> Thanks for all your help.
> Aaron
>
> On Wed, Sep 7, 2016 at 9:36 AM, Peter Steinbach <steinb...@scionics.de>
> wrote:
>
>> Hi Mr Candy (I am still getting a heck out of cottoncandycoder, sorry :D )
>>
>> 1) the way you do it, is not really the way cmake should be used AFAIK.
>> > In my CMakeLists.txt file I included:
>> > set( CMAKE_CXX_FLAGS  "-L/Applications/MAMP/Library/lib -lmysqlclient
>> > -lpthread -lz" )
>> > set( CMAKE_EXE_LINKER_FLAGS  "-lmysqlclient -lpthread -lm -lz" )
>>
>> change this to:
>> #I assume you have something like this somewhere
>> add_executable(my_exe_name SOURCES my_exe_name.???)
>> #here comes the "magic"
>> link_directories(/Applications/MAMP/Library/lib)
>> target_link_libraries(mysqlclient pthread m z)
>>
>> In theory, if all those dependencies are available at cmake-invocation,
>> this should emit compiler calls that produce your binary and link
>> mysqlclient into it (by default with using RPATH, see the docs on this:
>> https://cmake.org/cmake/help/v3.0/prop_tgt/MACOSX_RPATH.
>> html#prop_tgt:MACOSX_RPATH
>> ). Depending on whether you wanna distribute your binary and cannot be
>> sure if (at build time) pthreads etc are available, there are cmake find
>> modules for pthreads and libz (FindThreads, FindZLIB) which you can use.
>> libm should come with the libc of the system AFAIK.
>>
>> I also just checked but up to cmake 3.5, there is no MYSQL Find module.
>> Which is kinda sad as there is a FindPostgreSQL module. :( If there would
>> be, you could use it in a (hopefully) platform independent way and not
>> bother with finding the right paths to libmysqlclient.
>>
>> 2) The compiler flags you posted do not explain, why Xcode apparently
>> sets the rpath inside the binary and your cmake script doesn't (haven't
>> seen the full CMakeLists.txt of your project yet).
>>
>> I hope the above gets you going.
>>
>> @cmake developers: it would be nice to have more obvious pointers to
>> cmake example projects like an example SDK or so. If there is, please let
>> me know. I only found this:
>> http://www.vtk.org/Wiki/CMake/Examples#Finding_Packages
>> but that's tied to vtk.
>>
>> Best,
>> peter
>>
>> On 09/06/2016 08:12 PM, Cotton Candy wrote:
>> > Peter,
>> > In XCode I have this list of "settings" that includes
>> > "Other Linker Flags" that I have set to "-lmysqlclient -lpthread -lm
>> -lz"
>> > and
>> > "Other C++ Flags" that I have set to "-L/Applications/MAMP/Library/lib
>> > -lmysqlclient -lpthread -lz"
>> >
>> > Maybe these explain why things work when I build with XCode, but not
>> with
>> > CMake.
>> >
>> >
>> > but when I run the make it always says it is ignoring these (e.g.
>> "warning:
>> > argument unused during compilation: '-L/Applications/MAMP/Library/
>> lib'").
>> >
>> > Thanks again for you help.
>> > Aaron
>> >
>> >
>> >
>> >
>> >
>> > On Tue, Sep 6, 2016 at 2:20 PM, Peter Steinbach <steinb...@scionics.de>
>> > wrote:
>> >
>> >> Aaron,
>> >>
>> >> it's about the way that you compile your binary and link libmysqlclient
>> >> into it. I guess (@all: please correct me if I am wrong) as I don't
>> know
>> >> how you use cmake to build your libraries/binaries, that you don't set
>> the
>> >> rpath of libmysqlclient inside your binary. Doing so will ensure that
>> the
>> >> absolute path of libmysqlclient is stored into your binary, so that the
>> >> runtime environment can pick it up and use (keeping fingers crossed
>> that
>> >> the path is still valid). The alternative to doing so, is linking
>> against
>> >> the static version of libmysqlclient (which comes at a cost on another
>> >> front as well).
>> >>
>> >> Best,
>> >> P
>> >>
>> >
>>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to