Unity3D Openfeint Xcode 4.1 C++ headers compiled as C - xcode4

I am trying to integrate the openfeint unity plugin into our game,
I got the xCode project, followed the steps from Openfeint Support Page but when trying to compile the proiect openfeint's header files are compiled as C files not as C++.
I tried almost everything without cuccess. I added the -ObjC build flag,
and GCC_OBJC_CALL_CXX_CDTORS = YES in the setting of GCC .
Any ideas what went wrong?
P.S. I also get the error message from Openfeint.h:
#ifndef __cplusplus
#error "OpenFeint requires Objective-C++. In XCode, you can enable this by changing your file's extension to .mm" #endif
Thanks in advance

You shouldn't treat header files as compilation targets at all.
Either you are somehow marking header files for compilation, or including them in .m files, which are Objective-C (as opposed to .mm files, which are Objective-C++). Assuming the latter — which is the more likely scenario — you can simply rename the affected .m files to .mm.

Related

Include local library

I'm trying to copy a couple of libraries I created to my local sketch folder, as instructed in the Arduino Library Tutorial
My folder structure is the following
Documents\Arduino\MySketch\
MySketch.ino
libraries\
Timer\
Timer.h
Timer.cpp
I get the following error
fatal error: Timer.h: No such file or directory
#include <Timer.h>
Note that this works just fine if I move my libraries to the C:\Program Files (x86)\Arduino\libraries folder, but I really don't want to keep them appart from my source since I can not check them to my git repository.
I think I'm following the instructions given in the tutorial precisely. I just googled about this and found several similar problems, but no solution. It's supposed to be working in recent versions of the IDE (I'm on 1.8.5 on Windows 10).
I also tried to include the libraries using double quotes instead of angle brackets but I got the same error.
Can you please let me know how to fix this problem?
Thanks
Recent versions of the Arduino IDE do recursive compilation of the src subfolder of the sketch folder. So to achieve your goal, you will want a folder structure that looks something like this:
MySketch
|_MySketch.ino
|_src
|_Timer
|_Timer.h
|_Timer.cpp
Then the #include directive in the sketch should look like this:
#include "src/Timer/Timer.h"
It's quite common for Arduino libraries to use incorrect syntax for their internal #include directives. For example, Timer.cpp might contain this line:
#include <Timer.h>
That doesn't cause a problem when the library is installed normally but it will cause an error when you try to use the library bundled with a sketch. The solution is to edit the library to use the correct syntax:
#include "Timer.h"
It seems to me that the solution looks fine if libraries/Timer is used only by this sketch. What if you have several projects {git_repo}/sketch_{n}/sketch_{n}.ino calling the same class Timer(.h, .cpp) ?
If you want to avoid code duplication (and you do), then you may put them into {git_repo}/libraries/. You will still be able to check them out into git. However, this is painful because it requires that each time you modify one file into the library, you need to :
delete the dir C:\Program Files (x86)\Arduino\libraries\Timer
reload the ".zip" (from {git_repo}/libraries/Timer) from the Arduino IDE
Very painful.
What you could do is create a symbolic link from {git_repo}/libraries/your_library to C:\Program Files (x86)\Arduino\libraries\your_library
On Ubuntu that would be :
cd ~/Arduino/libraries/ # where Arduino stores the libs
rm -rf Timer/ # deleting your library if exists
ln -s ~/dev/code/[MY_PROJECT]/libraries/Utils/Timer Timer
The Arduino IDE will know your library exists, and would recompile it automatically if Timer.{h,cpp} (from your git_repo) was modified in between.

Qt Creator: include directories

I'm trying to create a GUI and i'm having issues with some header files that the program needs and uses.
If i click on the function in the main.cpp it takes me to the header file. But for some reason when i compile the program I get "undefined reference to " the function in main.cpp.
Ive tried to add the path of the include folder where the header file in the .pro file but it didnt work.
It seems to me that Qt sees the function but somehow it doesnt compile.
Any suggestions? Thank you
This is my solution to the case of “undefined reference to” error,
In .pro file append or modify this line:
QT += core gui sql printsupport network websockets
Maybe that's the same thing for you.
There is a similar description in the Qt document
Header: #include <QWidget>
qmake: QT += widgets
You can find which header file corresponds to which module
for some reason the compiler did not see the library that the header file needed. it was specified in the makefile but it didnt work.
in the .pro file i added
LIBS += -lmylib
and that fixed the issue. Thank you for your help
Including a header so the compiler can find the declarations of classes/methods/functions is one thing.
Adding source code or libs so that the definition of the declared facilities can be found by the linker is another.
I get "undefined reference to " the function in main.cpp
This is a linker error. You either haven't added your own source files to the project, or any third-part libs you use. Open the context menu of your project in the left Creator pane and select "Add existing file..." for the first case or "Add library..." for the second.
And in the next step you should spend some time reading the Creator manual as well as some basics about C++ and compiling in general. All beginner questions like the above have already been answered multiple times, you just have to search for them.

Unable to add include path in Qt Creator

I've downloaded a C++ project which uses Boost. It's rather complicated and plenty of files reference its parts, like:
#include <boost/graph/fruchterman_reingold.hpp>
I've put Boost directory in the project folder and added INCLUDEPATH += "C:/Programming/my-project" in the .pro file but for some reason Qt keeps telling me "No such file or directory" about every single file. Now note that if I change the paths to absolute the references start working. I've ran Qmake explicitly but still get the same problem. What can I do about it besides changing all paths to absolute?
I'm running Qt Creator 3.3.0, Qt 5.4.0, the compiler is MinGW 4.9.1.
So I've figured it out. Apparently the project had several projects inside but I wasn't aware that I had to change .pro files in every single one to tell the compiler to add a new path. After I did it the problem was solved. Thank you for your time, people.

Qt creator can not include opencv header files

I have downloaded qt-5.0.0 for windows.
http://releases.qt-project.org/qt5/5.0.1/qt-windows-opensource-5.0.1-msvc2010_32-x86-offline.exe
I have added INCLUDEPATH += C:\opencv\build\include in the .pro file.
Opencv 2.4.3 is already installed.
When I include header file in qtcreator :
#include <opencv2/opencv.hpp>
There is compilation error : can not find opencv2/opencv.hpp
Any ideas ??
I found the solution. In Qt Creator, goto Projects on the left pane ( ctrl+5), then Build Environment -> Use System Environment, click on Details. Edit LIB variable. Add here.
Things to check:
does C:\opencv\build\include\opencv2\opencv.hpp actually exist?
does the compile command (which you can check in the Qt Creator "compile output" window) show -IC:\opencv\build\include argument in the compile command?
qmake should be run automatically after modifying the .pro file, but re-run it manually just in case (for example from Build menu), as suggested by the first answer
this should not have any effect in issue like this, but just in case: if you are using "shadow build" (which is a good idea), make sure the source dir is clean of any generated files
The correct header files are:
<opencv2/core/core.hpp>
<opencv2/imgproc/imgproc.hpp>
<opencv2/highgui/highgui.hpp>
… and so on. The include of "opencv.h" is deprecated!
It also does not work anymore for QtCreator auto-completion.
The solution is to update your sources to use the correct header files.
After any change made to .pro file , Do right-click on project folder and click on run qmake .
Well, I just ran into this problem tonight. luckily enough, after taking a fair time, the solution was found. If your project is managed by qmake, and Qcreator is used, just go to the Build->Run qmake, then build and run your project. A tip, whenever you change your *.pro file, remember to rerun Build->Run qmake, because that will reconfigure your project.
If this helps you, please give me a thumb up :)

Undefined references - I'm including correct header

I'm trying to subclass from ProjectExplorer::ProjectExplorerPlugin but I'm getting error telling me about undefined references. Any ideas how to fix it?
class MyPluginPlugin : public ProjectExplorer::ProjectExplorerPlugin
{
Q_OBJECT
...
};
error: undefined reference to `imp__ZN15ProjectExplorer21ProjectExplorerPluginC2Ev'
The fact that you don't get a compilation error, but an undefined reference usually means that your project knows where the header files are, but it doesn't know where the library is which contains the already compiled source code.
I've never written a plugin for Qt Creator but I've taken a quick look at its source code structure and I see the following options:
Option A)
There is a projectexplorer.pro file in Qt Creator's source under src/plugins/projectexplorer. You could manually build that project in order to get a ProjectExplorer.lib (plus a .dll or a .a) and then reference this library.Example: Assuming the library would be created in the same directory as its .pro file (I have no idea if it is like that) and you created your plugin withing Qt Creator's source under src/plugins/myplugin, you would define your LIBS variable like this:
LIBS += -L../projectexplorer \
-lProjectExplorer
The first line adds "../projectexplorer" as an additional library directory and the second line adds "ProjectExplorer" as a library to search in any of the defined directories (it automatically adds the OS-specific file extensions like .lib on windows etc).
Obviously if your project or the library is located somewhere else, you need to change the first line accordingly.
Option B)
You could include the source and header files of the projectexplorer directory to your own .pro file using the HEADERS and SOURCES variables. I'm not sure if this wouldn't interfere with any other plugins (including projectexplorer itself) though.
Option C)
There probably is a way to include the projectexplorer.pro file so that you have a master project which first builds the project explorer library and then your own plugin. This would be the safest way to go as it ensures the Project Explorer library is built and up-to-date before your own project is linked against it.
However I have limited experience on this.
If anyone reading this can give a detailed explanation on this option, feel free to edit or provide your own answer.
If you are using Qt Creator built from source coded after April 2013 which includes Commit: #66a3553 - make library and plugin dependencies declarative, then you can simply specify dependencies for your plugin in its .pro file:
# myplugin.pro
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer

Resources