astellato / ofxSyphon

An OF add-on for using the Syphon framework.
Other
193 stars 57 forks source link

Make build issues #32

Open bangnoise opened 8 years ago

bangnoise commented 8 years ago

ofxSyphon source isn't being compiled for Makefile builds

Running make in example-Basic gives (shortened):

HOST_OS=Darwin
Compiling OF library for Release
HOST_OS=Darwin
HOST_OS=Darwin
HOST_OS=Darwin
Done!

Compiling example-Basic for Release
HOST_OS=Darwin
cat: obj/osx/Release/.compiler_flags: No such file or directory
Compiling /Users/tom/Development/OpenFrameworks/of_v0.9.3_osx_release/addons/ofxSyphon/example-Basic/src/main.cpp
...
Compiling /Users/tom/Development/OpenFrameworks/of_v0.9.3_osx_release/addons/ofxSyphon/example-Basic/src/ofApp.cpp
...
Linking bin/example-Basic for osx
...
Undefined symbols for architecture x86_64:
  "ofxSyphonClient::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      ofApp::setup() in ofApp.o
  "ofxSyphonClient::draw(float, float)", referenced from:
      ofApp::draw() in ofApp.o
  "ofxSyphonClient::setup()", referenced from:
      ofApp::setup() in ofApp.o
  "ofxSyphonClient::ofxSyphonClient()", referenced from:
      _main in main.o
  "ofxSyphonClient::~ofxSyphonClient()", referenced from:
      ofApp::~ofApp() in ofApp.o
      ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
  "ofxSyphonServer::publishScreen()", referenced from:
      ofApp::draw() in ofApp.o
  "ofxSyphonServer::publishTexture(ofTexture*)", referenced from:
      ofApp::draw() in ofApp.o
  "ofxSyphonServer::setName(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      ofApp::setup() in ofApp.o
  "ofxSyphonServer::ofxSyphonServer()", referenced from:
      _main in main.o
  "ofxSyphonServer::~ofxSyphonServer()", referenced from:
      _main in main.o
      ofApp::~ofApp() in ofApp.o
      ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
  "_glutDragEventFunc", referenced from:
      ofAppGlutWindow::setup(ofGLWindowSettings const&) in libopenFrameworks.a(ofAppGlutWindow.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [bin/example-Basic] Error 1
make: *** [Release] Error 2
bangnoise commented 8 years ago

@arturoc I wonder if you could comment on how this ought to work. I thought files in addons/ofxSyphon/src should be compiled automatically..?

bangnoise commented 8 years ago

Possibly because files are .mm (Objective C++) rather than .cpp.

samkuhn commented 8 years ago

I'm also having the same issue and no luck finding a solution so far.. please god don't make me have to open xcode! ;)

jeraman commented 7 years ago

I was able to partially compile the file using:

make LDFLAGS="-arch i386"

However, the resulting binary doesn't run and no frameworks are linked it. Tried to manually link Syphon framework (as well as all others required by OF) using LDFLAGS, with no success so far.

Would anyone have a direction on how to solve this issue?

ThomasLengeling commented 7 years ago

@jeraman I just compiled the project code, I didn't add that flag.

But I did change the the ofMain to this:

int main( ){    
    ofSetupOpenGL(640, 360, OF_WINDOW); 
    ofRunApp( new ofApp());
}

If you create a new project with the addon, make sure you copy the Syphon.framework to the project and to the bin directory

jeraman commented 7 years ago

Thanks for the update, @ThomasLengeling!

I tried your suggestion but the problem persists. Maybe I'm missing something?

What OS X version are you on? And what oF version are you using?

ThomasLengeling commented 7 years ago

I'ma using the GitHub release, and mac osx 10.12, what is your error output?

jeraman commented 7 years ago

Thanks for the info! I'm on OS X 10.11.6 and oF 0.9.8. I'll try to test in a setup similar to yours to see what happens.

My output is exactly the same as the one posted by @bangnoise:

Undefined symbols for architecture x86_64:
  "ofxSyphonClient::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      ofApp::setup() in ofApp.o
  "ofxSyphonClient::draw(float, float)", referenced from:
      ofApp::draw() in ofApp.o
  "ofxSyphonClient::setup()", referenced from:
      ofApp::setup() in ofApp.o
  "ofxSyphonClient::ofxSyphonClient()", referenced from:
      _main in main.o
  "ofxSyphonClient::~ofxSyphonClient()", referenced from:
      ofApp::~ofApp() in ofApp.o
      ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
  "ofxSyphonServer::publishScreen()", referenced from:
      ofApp::draw() in ofApp.o
  "ofxSyphonServer::publishTexture(ofTexture*)", referenced from:
      ofApp::draw() in ofApp.o
  "ofxSyphonServer::setName(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      ofApp::setup() in ofApp.o
  "ofxSyphonServer::ofxSyphonServer()", referenced from:
      _main in main.o
  "ofxSyphonServer::~ofxSyphonServer()", referenced from:
      _main in main.o
      ofApp::~ofApp() in ofApp.o
      ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
      non-virtual thunk to ofApp::~ofApp() in ofApp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [bin/example-Basic] Error 1
make: *** [Release] Error 2
ThomasLengeling commented 7 years ago

strange, make sure the .framework is linked to the project. I what I did, I created a new project with the projectGenerator and then included the .framework to the Xcode project, change the ofmain.cpp and included the .framework to the project bin directory. Hope that helps Thomas

jeraman commented 7 years ago

included the .framework to the Xcode project

Oh, but the basic example compiles fine inside XCode, this is not my issue.

The issue appears when I'm compiling it without XCode, by using a makefile.

Is this what you're able to do?

timredfern commented 6 years ago

I managed to get a Makefile build with ofxSyphon

I had to change the extension of the .m and .mm files in ofxSyphon/src and ofxSyphon/libs/Syphon/src and to .cpp - I can't work out why $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk isn't picking up the m's

I copied the Syphon framework into /Frameworks in my project and then added

PROJECT_LDFLAGS = -FFrameworks -framework Syphon

I had to copy the framework into bin/my.app/Contents/Frameworks to run it

(The examples in ofxSyphon don't build with recent OF because they use GLUT)

bigfish247 commented 3 years ago

Hi, is there any solution for visual code c++ complier? The error messages showed up same as @jeraman. I think the problem is mm file, but I couldn't modify it correctly.

bangnoise commented 3 years ago

Looks like OpenFrameworks' compile.addon.mk needs to add support for .m and .mm files in addons.

bangnoise commented 3 years ago

Will require this PR be merged openFrameworks/openFrameworks#6652 - plus a change to copy the Syphon framework to the built app's Frameworks directory during builds, matching the behaviour of Xcode builds.

danomatika commented 2 years ago

As a followup, building is working for me with the oF 0.11.2 release and Xcode 13.2 on macOS 11.6.7 but runtime linking fails due to the missing framework:

 % make RunRelease
dyld: Library not loaded: @loader_path/../Frameworks/Syphon.framework/Versions/A/Syphon
  Referenced from: /Users/danomatika/src/of/of_v0.11.2_osx_release/addons/ofxSyphon/example-Basic/bin/example-Basic.app/Contents/MacOS/./example-Basic
  Reason: image not found
/bin/sh: line 1: 35286 Abort trap: 6           ./example-Basic
make: *** [RunRelease] Error 134

It seems the Copy Frameworks step works fine when building with Xcode but either isn;t called or doesn't exist when using the Makefile build. This is strange as I thought the oF makefile build just invokes xcode build using the same project.

The workaround is to manually copy the Framework into the app bundle but I would think it should be done automatically...?

danomatika commented 2 years ago

plus a change to copy the Syphon framework to the built app's Frameworks directory during builds, matching the behaviour of Xcode builds.

Ah sorry, I see y'all are aware of this already. An approach we took for installing libtensorflow dylibs into project app bundles for ofxTensorFlow2 is a script which is called with a custom makefile build target or during the Xcode build run script phase: https://github.com/zkmkarlsruhe/ofxTensorFlow2/blob/main/scripts/macos_install_libs.sh This is less than ideal though, because it requires manually adding this step after generating the project files: https://github.com/zkmkarlsruhe/ofxTensorFlow2#macos. I am working on an additional script to automate these steps but, still, not as nice as 1. generate project files & 2. make.

danomatika commented 2 years ago

I have my approach working in a client project which uses ofxSyphon:

https://git.zkm.de/Hertz-Lab/Research/intelligent-museum/YoloOSC/-/commit/399a9efca1c04c4fce74a180445634f95fd62e91

I basically follow the same model as ofxTensorflow2: script to install the framework into the bundle and special makefile targets to run this after generating the app.

UPDATE: I'm pretty sure this breaks the code-signing but it's enough for the app to run on the build system.