using OF from eclipse

hi
i’m trying to compile with makefile because i want to port from codeblocks to eclipse

every example i compile i get the same result: no problem with make but when i execute the file a problem concerning libfmodex.sois raised (and it’s ok because .so file are loaded in compile time).

some advice?

alberto@zefiro:~/Documents/of_preRelease_v0062_linux_FAT/apps/examples/soundPlayerExample$ make
compiling object for: src/testApp.cpp
mkdir -p obj/Release/src
g++ -c -march=native -mtune=native -O3 -Wall -fexceptions -I. -I…/…/…/libs/FreeImage/include -I…/…/…/libs/fmodex/include -I…/…/…/libs/freetype/include -I…/…/…/libs/freetype/include/freetype2 -I…/…/…/libs/freetype/include/freetype2/freetype -I…/…/…/libs/freetype/include/freetype2/freetype/config -I…/…/…/libs/glee/include -I…/…/…/libs/gstappsink/include -I…/…/…/libs/gstappsink/include/gst -I…/…/…/libs/gstappsink/include/gst/app -I…/…/…/libs/poco/include -I…/…/…/libs/poco/include/Poco -I…/…/…/libs/poco/include/Poco/Net -I…/…/…/libs/poco/include/Poco/SAX -I…/…/…/libs/poco/include/Poco/Dynamic -I…/…/…/libs/poco/include/Poco/XML -I…/…/…/libs/poco/include/Poco/DOM -I…/…/…/libs/poco/include/Poco/Util -I…/…/…/libs/poco/include/CppUnit -I…/…/…/libs/rtAudio/include -I…/…/…/libs/openFrameworks/ -I…/…/…/libs/openFrameworks/communication -I…/…/…/libs/openFrameworks/app -I…/…/…/libs/openFrameworks/graphics -I…/…/…/libs/openFrameworks/sound -I…/…/…/libs/openFrameworks/utils -I…/…/…/libs/openFrameworks/events -I…/…/…/libs/openFrameworks/video pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --cflags -MMD -MP -MFobj/Release/src/testApp.d -MTobj/Release/src/testApp.d -oobj/Release/src/testApp.o -c src/testApp.cpp
compiling object for: src/main.cpp
mkdir -p obj/Release/src
g++ -c -march=native -mtune=native -O3 -Wall -fexceptions -I. -I…/…/…/libs/FreeImage/include -I…/…/…/libs/fmodex/include -I…/…/…/libs/freetype/include -I…/…/…/libs/freetype/include/freetype2 -I…/…/…/libs/freetype/include/freetype2/freetype -I…/…/…/libs/freetype/include/freetype2/freetype/config -I…/…/…/libs/glee/include -I…/…/…/libs/gstappsink/include -I…/…/…/libs/gstappsink/include/gst -I…/…/…/libs/gstappsink/include/gst/app -I…/…/…/libs/poco/include -I…/…/…/libs/poco/include/Poco -I…/…/…/libs/poco/include/Poco/Net -I…/…/…/libs/poco/include/Poco/SAX -I…/…/…/libs/poco/include/Poco/Dynamic -I…/…/…/libs/poco/include/Poco/XML -I…/…/…/libs/poco/include/Poco/DOM -I…/…/…/libs/poco/include/Poco/Util -I…/…/…/libs/poco/include/CppUnit -I…/…/…/libs/rtAudio/include -I…/…/…/libs/openFrameworks/ -I…/…/…/libs/openFrameworks/communication -I…/…/…/libs/openFrameworks/app -I…/…/…/libs/openFrameworks/graphics -I…/…/…/libs/openFrameworks/sound -I…/…/…/libs/openFrameworks/utils -I…/…/…/libs/openFrameworks/events -I…/…/…/libs/openFrameworks/video pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --cflags -MMD -MP -MFobj/Release/src/main.d -MTobj/Release/src/main.d -oobj/Release/src/main.o -c src/main.cpp
linking bin/soundPlayerExample
g++ -o bin/soundPlayerExample obj/Release/src/testApp.o obj/Release/src/main.o -L…/…/…/libs/fmodex/lib/linux -L…/…/…/libs/FreeImage/lib/linux -L…/…/…/libs/freetype/lib/linux -L…/…/…/libs/glee/lib/linux -L…/…/…/libs/gstappsink/lib/linux -L…/…/…/libs/openFrameworksCompiled/lib/linux -L…/…/…/libs/poco/lib/linux -L…/…/…/libs/rtAudio/lib/linux -Wl,-rpath=./libs -lopenFrameworks -lfmodex -lfreeimage -lfreetype -lGLee -loFappsink -lPocoFoundation -lPocoNet -lPocoUtil -lPocoXML -lRtAudio pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --libs -lglut -lGL -lGLU -lasound
cp -r …/…/…/export/linux/libs bin/

compiling done
to launch the application

cd bin
./soundPlayerExample

alberto@zefiro:~/Documents/of_preRelease_v0062_linux_FAT/apps/examples/soundPlayerExample$ ./bin/soundPlayerExample
./bin/soundPlayerExample: error while loading shared libraries: libfmodex.so: cannot open shared object file: No such file or directory
alberto@zefiro:~/Documents/of_preRelease_v0062_linux_FAT/apps/examples/soundPlayerExample$

EDIT: in codeblocks everything runs correctly!

Hi,

Check this [1] thread in the ubuntu forums, maybe can help you.

[1] http://ubuntuforums.org/showthread.php?t=1606261

as the makefile tells when it ends compiling you need to execute the binary from the bin directory:

cd bin
./soundPlayerExample

ohu, i feel stupid! it works! thanks!

i can compile with Eclipse Helios but with some problems (see bloew)
i tried to follow steb-by-step here http://forum.openframeworks.cc/t/of-in-eclipse-on-linux/435/0
but didn’t work (mayebe different eclipse and different openframeworks versions)

this is what i’ve done:

open eclipse helios cdt

  • file > new > project > Makefile Project with Existing Code

  • browse for an existing project location inside openframeworks directory, finish button

  • if it does not exists create a folder called ‘bin’ for binary complied files

  • build project

  • project properties > run/edbug settings > new > c/c++ applications

  • in main tab: in c/c++ applications browse for binary file just created inside folder bin

  • in arguments tab: uncheck the checkbox Use defaults, Working directory as ‘${workspace_loc:audioOutputExample}/bin’

loading external files (like external movie) seems to be ok

problems:
no code completition (!)

problems:
no code completition (!)

in the project preferences, select project references and add libs, addons and openframeworks and it will work

arturo, thanks for your answers

in project references i can add only existing projects, and in the workspace there are only examples imported as makefile project from existing code.

i tried to create a new empty c++ project and i imported filesystem folder my_of_path/libs/* and i added that project but… nothing

another test was:
in c/c++ general > path and symbol added:
libopenframeworks.a as libraries
my_pf_path/libs/openframeworksCompiled/lib/linux as library paths
… but nothing

in the github version there’s eclipse projects for libs, addons and openframeworks, from the android version, but they have also linux configs. if you download from github, you’ll only need to import that projects.

then use your method to create new projects for examples or your own projects

it works perfectly! thanks. ;D
android version is a miracle for eclipse users!

(but how does it works? i thought android coding was permitted only in java and it derivates as jython and jruby)

bytheway, right now i have:
myhome/of/extracted_and_compiled_openframwroks --> “clean” openframeworks directory
myhome/of_workspace/ --> empty directory for eclipse .metadata and not mix it with existing ones or with codeblocks workspace

now, for create new app i tried to use ofProjectManager but i can’t do it well.

so i had copied the emptyExample in:
myhome/of/apps/myApps/my_new_example
create bin folder and edit addons.make if needs
import makefile project in eclipse.

now my question is: ok this works fine. but in this way i dirty my original and clean openframeworks folder.
manage everything in makefile is shiny and cool, is standard, is *nix style (imho), is IDE indipendent, it’s OK.

what is the best way to handles this with eclipse? i have of_workspace as an empty folder only for eclipse metadata, and for new project i have to “dirty” the openframeworks in of/apps/myApps directory because of …/…/ stuffs in makefile.

is it possible to have something like:

/openframeworks_libs --> clean library, all libs, never touch it!
/workspace/example_one_place_to_start
/workspace/test_something_weird
/workspace/whatever
/workspace/this_is_actually_current_apps_folder

without revolution the makefile?

(for examples
in actionscript3/flex i had some “library project” - that i never touch - where i put all libraries and i linked that project as a resources
in java for jogl or processing.org projects the same, all .jar and other needs in a separate clean directory,
in python… mhmm for pygame or pymt or vtk projects is different because of python library system, but it is another story because all compilations headache are nonsense, just open a python shell and try import - and because python rocks in easiness :))

keep separate the core and libs from the folder where are examples and weird tests i think should be great. for testing, for up/down-grading libraries versions, for distributing finished project, for managing folders and gets hand dirty
but mayebe this is not good for design decisions here in openframeworks… which ones in this case?
or - most probabilly - i’m not focusing the point because of headache in makefile/compilation missunderstanding. :-[

sorry but english is not my first language, i hope not annoying and exaplain well what i mean.

How i’ve been working with eclipse is by creating a workspace in my myApps folder or however you want to call it. ofProjectManager doesn’t make very much sense now.

Once you create the workspace, import libs, addons, libs/openFrameworks and create a new makefile project in apps/examples/emptyExample

That way when you want to create a new project you just need to copy the emptyExample. since the workspace is pointing to your myApps directory it will be created there by default.

with the new makefiles you can also create projects wherever you want. just open config.make and edit:

  
OF_ROOT = ../../..  

and change it to the absolute path to your OF install that way the makefile will be able to find it no matter where you create the projects. so actually you can create the eclipse workspace in any place

this rocks!

hei,
i don’t use anymore eclipse (because some errors in importing ofxXmlsSettings and ofxControlPanel - http://forum.openframeworks.cc/t/basic-questions-about-ofxcontrolpanel/6032/0 if someone have same problem or can fix it please contact me!! )
also for c++ projects i came back to my best editor in linux: vim ^___^ (i came in eclipse for android project but for now i just use OF in my computer, android device will come in future).
vim is a great tool, fully customizable and real light IDE.

here i attach a base eclipse project.

it contains:
.project → file for eclipse project
.cproject → file for eclipse CDT plugin for c++
.settings → very important folder. normally when you edit or create some configurations lauch for a project eclipse save this conf infos in some dark place in .metadata/eclipse.voodoo.plugin in .metadata folder of eclipse workspace. use .settings directory is a little trick to put configurations inside project, i think this is very usefull for openframeworks project. inside this folder there is a file that has to renamed.

so, for create new project do this:
replace all occurrences of emptyProject with newProjectName from .project, .cproject, “.setting/emptyExample\ Default.launch”
rename “.setting/emptyExample\ Default.launch” in “.setting/newProjectName\ Default.launch”

note that i put my eclipse workspace in openframeworks_path/apps/eclipse_workspace as arturo advice me.
in “.setting/emptyExample\ Default.launch” there is the copmplete path to the workspace, in my computer is /home/alberto/Software/of/apps/eclipse_workspace/emptyExample/bin/emptyExample , remember to replace it!

when you fix the path in .settings you should do something similar:

alberto@zefiro:~/Software/of/apps/eclipse_workspace$ cp -r emptyExample/ newCoolApps
alberto@zefiro:~/…/$ cd newCoolApps/
alberto@zefiro:~/…/newCoolApps$ sed -i ‘s/emptyExample/newCoolApps/g’ .project
alberto@zefiro:~/…/newCoolApps$ sed -i ‘s/emptyExample/newCoolApps/g’ .cproject
alberto@zefiro:~/…/newCoolApps$ sed -i ‘s/emptyExample/newCoolApps/g’ .settings/emptyExample\ Default.launch
alberto@zefiro:~/…/newCoolApps$ mv .settings/emptyExample\ Default.launch .settings/newCoolApps\ Default.launch

it should work but for sure i’m missing something, let me know if something is wrong.
hope it helps!

EDIT:
i can’t upload file as .tr.gz so i renamed it in .zp but still didnìt work so i renamed in .gif.
it missed bin/ and obj/ directory because the file attachment was limited in size, compile it with make before importing in eclipse

so i added the libs, addons and libs/openframeworks into my eclipse workspace, and the indexer runs amok on me - loads of “method could not be resolved” or e.g. “Type ‘string’ could not be resolved”. It actually builds and runs projects fine, only the eclipse code indexer fails.
I got a suspicion that it maybe can’t follow the inclusions we make in the makefile, or something?

I already set the references between the projects, doesn’t help.
I already added “string” to Window/Preferences/Indexer - files to index up-front. didn’t help.
Ideas, anyone?

Ah yes, I’m running the current Eclipse, Indigo, with CDT 8.0.0.etc…

hm, so it seems the error was because for the openframeworks project, the Toolchain was not selected properly, therefore the standard include paths were not set in the paths and symbols section.

another interesting behaviour: If i clean a project (RMB over a project -> clean project), then the openframeworks project gets cleaned, too. the openframeworks project is in its project references of course, but I think the oF base project shouldn’t automatically rebuild.
this makes it in essence impractical to clean single projects (for example if you took a quick look at an example, but don’t need it anymore, you clean to get rid of binaries and obj files)

Is it possible to make the base project _not_ clean when a user project is cleaned. or is there a usecase for this which i miss?

this is possibly a but in eclipse CDT: https://bugs.eclipse.org/bugs/show-bug.cgi?id=317162#c4
but I could not find out what the actual behaviour in CDT8 (in Indigo) is supposed to be.
Also, possibly CDT projects should not be referenced in the “normal” project references, but in c++general/paths and symbols/references…

btw, what’s the correct way to debug using eclipse. I get all kinds of funky errors like “No source available for main()” when debugging. Should there be a build configuration for debug be added in addition to the “linux” one?
I could do some debugging by running make Debug for a project in the console, and starting the resulting bin in Eclipse, but that can’t be the correct way…

http://stackoverflow.com/questions/2324602/no-source-available-for-main-error-when-debugging-simple-c-in-eclipse-with
http://stackoverflow.com/questions/6306463/how-to-let-eclipse-run-different-make-targets-before-run-debug

thanks to the previous posts I am now able to use eclipse for openframeworks without any restrictions (even debugging).

for debugging i created an additional build and run config.
under Project -> Properties -> C/C++ Build in the “Behavior” tap you have to change “Build (incremental build)” from “all” to “Debug”.
for the corresponding new run configuration its important to browse for the “pathTo/yourexample/bin/yourexample_debug” binary (C/C++ Application) and set the new Debug configuration as “Build configuration” (both in the “Main” tap).

by debugging via the new run config eclipse automatically builds yourexample_debug (if its not up to date).

if openframeworks itself has changed Release and Debug will be both rebuild.

I hope this helps (someone).

thx, nice info, I’ll try that next time I need it. It’s a shame that there’s no less convoluted way to achieve this. :-/

with the new eclipse release JUNO things get a little bit easier. you don’t have to create your run configs for each project because after building your app eclipse recognizes the binaries by itself.
for debugging you still need a second build config as I’ve described above but then you only have to chose the debug build and hit debugging. don’t forget to set “Use Active” as “Build Configuration” in the default run config.