Search code examples
cwiiuse

Including wiiuse.h in C


I'm running OSX 10.9.2

I've successfully compiled and run the example program for wiiuse. However, this meant making a makefile with CMake, then running make. I am stuck, though, as to how I can compile my own program using this library. As a first step, I'm trying to recompile the example program on my own. I've made a directory which contains example.c and wiiuse.h. When I run

clang example.c -lwiiuse -o example

I get

ld: library not found for -lwiiuse
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What gives? Why can't include the library?


Solution

  • Since the comment happened to work for the OP, I am writing it into an answer.

    On a regular Unix, one would run gcc with the option -Lpath/to/location/of/so_file.

    When running the compiled binary, one would then set LD_LIBRARY_PATH to include the same path.

    Apparently this approach also works for OS X.

    To set LD_LIBRARY_PATH when running, simply prefix the assignment command before the actual program:

    LD_LIBRARY_PATH=/path/to/folder/containing/my/lib ./example