Closed kalsan closed 4 years ago
The links must be after the source.
Build and install noson as shared lib:
mkdir build && cd build cmake .. -DBUILD_SHARED_LIBS=ON make sudo make install
The sample program:
#include <noson/sonossystem.h>
#include <noson/sonosplayer.h>
#include <noson/contentdirectory.h>
#include <noson/didlparser.h>
#include <noson/imageservice.h>
#include <noson/filestreamer.h>
#ifdef HAVE_PULSEAUDIO
#include <noson/pulsestreamer.h>
#endif
SONOS::System *gSonos = 0;
SONOS::PlayerPtr gPlayer;
int gDebug = 0;
void handleEventCB(void* handle)
{
fprintf(stderr, "#########################\n");
fprintf(stderr, "### Handling event CB ###\n");
fprintf(stderr, "#########################\n");
}
int main (int argc, char** argv) {
gSonos = new SONOS::System(0, handleEventCB);
if (gSonos->Discover())
{
printf("Discovered !!!\n");
}
delete gSonos;
exit(0);
}
Then compile you program: note the link follows the source or object file
g++ -o binary main.cpp -lnoson
If you want to use the static lib:
g++ -o binary main.cpp /usr/local/lib/libnoson.a -lpthread -lz -lssl -lcrypto -lFLAC++ -lFLAC -lpulse-simple -lpulse -lm -lrt
./binary
#########################
### Handling event CB ###
#########################
Discovered !!!
#########################
### Handling event CB ###
#########################
Thanks a lot! The static lib worked right away, the shared lib approach after running sudo ldconfig
. Thank you very much for your blazing fast and very helpful reply. I'll happily code on.
After installing, the library, I'm currently using
gcc -lnosonos mystuff.cpp
in the makefile. However whatever I'm trying to compile, I'm getting linker errors. For instance, here's a minimal example:The error message for this example is:
What do I need to feed to my linker in order to be able to write noson code?