I want to write GTK+ programs in Netbeans(version 6.9) in Ubuntu. Now I can compile GTK+ program via gcc compiler. But when write programs in Netbeans IDE, I can't build programs. The compiler sends me this error:
main.cpp:9:17: fatal error: gtk/gtk.h: No such file or directory'
I searched this error in google and pass steps in this site, but still it dose not work. I also pass following steps for solving my problem:
Set ProjectProperties/Build/C(C++) Compiler/additional Options to pkg-config --cflags gtk+-2.0
Set ProjectProperties/Build/Linker/Additional Options to pkg-config gtk+-2.0 --libs
Add ProjectProperties/Build/C(C++) Compiler/Include Directories and Tools/Options/cc++ /Code assistance to following headers:
/usr/include/atk-1.0
/usr/include/pango-1.0
/usr/include/gio-unix-2.0/
/usr/include/glib-2.0
/usr/lib/x86_64-linux-gnu/glib-2.0/include
/usr/include/freetype2
/usr/include/libpng12
/usr/include/gtk-2.0
/usr/lib/gtk-2.0/include
/usr/include/cairo
/usr/include/gdk-pixbuf-2.0
/usr/include/pixman-1
These steps don't solve my problem. IDE also draws a yellow line in the #include <gtk/gtk.h> line of code. How can I solve my problem?
Setup a C GTK+ Project in Netbeans
Create a C Project (not a C++).
Open the Project Properties window.
Go to "Build -> C Compiler".
In "Include Directories", add ALL the paths for GTK+ include requirements:
(assuming The root is in "C:/libs/c++/gtk"):
C:/libs/c++/gtk/include;C:/libs/c++/gtk/include/atk-1.0;C:/libs/c++/gtk/include/cairo;C:/libs/c++/gtk/include/fontconfig;C:/libs/c++/gtk/include/freetype2;C:/libs/c++/gtk/include/gail-1.0;C:/libs/c++/gtk/include/gdk-pixbuf-2.0;C:/libs/c++/gtk/include/gio-win32-2.0;C:/libs/c++/gtk/include/glib-2.0;C:/libs/c++/gtk/include/gtk-2.0;C:/libs/c++/gtk/include/libpng14;C:/libs/c++/gtk/include/pango-1.0;C:/libs/c++/gtk/include/pixman-1;C:/libs/c++/gtk/lib;C:/libs/c++/gtk/lib/glib-2.0/include;C:/libs/c++/gtk/lib/gtk-2.0/include
In "Additional Options", set:
$$(pkg-config --cflags --libs gtk+-2.0)
Go to "Build -> Linker".
In "Additional Library Directories", set the same values as in Point 4 (the "Include Directories" content).
In "Additional Options", set the same as in Point 5 (the "Build -> C Compiler -> Additional Options" content).
After this, your GTK+ project in Netbeans should be Compilable/Runnable. Working in Windows 7, Netbeans 7.3.
Related
I have a C library which I need to use in my ongoing Xcode project. I used Cmake to build and install that Library. I gave the paths to Headers files and I can include the files into my Xcode project. However, when I run the project it says:
linker command failed with exit code 1 (use -v to see invocation)
I suspect that problem is with Linker Flags. I haven't included any Linker Flags and I don't know which flags do I need to add. Please tell me where in the library would I get all the required Linker Flags.
git hub link of the library which I want to add:
https://github.com/cbalint13/pba
From xcode left side window.
Under Project Navigator, click on your project, click on build settings.
Select "All" and "Combined" sections, then search for "Linker Flag"
Don't forget to switch to your target's build settings as well. As you might change just the "Project", not the "Target".
I am using Qt version 5.5.1 (but with the 5.6.1 GUI), I am compiling with MSVC++ Compiler 10.0, and I have checked the "Use jom instead of nmake" option in the Options -> Build & Run -> General menu. I am using the latest version of cmake, and the Options -> Build & Run - > Kits -> CMake generator is set to "CodeBlocks - NMake Makefiles". To be honest, I do not know what that last option does, it is just the default.
I am building and running through the QT creator IDE.
If I add -j to the "tool arguments" in Projects -> Build&Run -> Build Steps, then when I try to compile I get the error:
NMAKE:-1: error: U1065: invalid option 'j'
However, I have "Use jom instead of nmake" selected so it should use jom and accept this argument, shouldn't it?
Have I missed out a step?
I cannot find any instructions on how to do this, and the only tutorials I can find to compile using jom are compiling through the command line, which I do not want to do.
edit: This is a different question from How do I utilise all the cores for nmake? as this question is specifically asking why the Jom solution (suggested as an answer in that question) is not working with my set up.
edit 2: I think I may have found out why. This bug report suggests that you need to use the "CodeBlocks - NMake Makefiles JOM" option in the kits -> cmake generator options.This is only supported with QtCreator 4.2.1 and above. However, I have this and it still does not work. I now get the error:
C:\Program Files\CMake\share\cmake-3.8\Modules\CMakeTestCCompiler.cmake:51: error: The C compiler "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/GIT/CorteX/build/Debug/CMakeFiles/CMakeTmp
Nmake file can be natively used by Jom, thus the cmake generator doesn't not need to be changed from the default nmake generator in the build configuration. The cmake generator is what converts your cmake to your native build system format (e.g. make, or nmake).
(i.e. Projects > Manage Kits ... > Build & Runs > Kits. choose your kit. I have my Cmake generator: set to "CodeBlocks - Nmake Makefiles, Platform: , Toolset: " ).
The only change you then need is to add a custom build step to run jom.exe and disable the default build step, as in Qtcreator JOM setup.
N.b. jom.exe must be in your PATH variable for QtCreator to find it.
jom requires that -j , where you set the number of processes, e.g. jom -j4. You can't use just -j without a count.
I used Cmake gui and the FindBoost module to add Boost as a dependency in my visual studio 2010 c++ project. I set the parameter that tells FindBoost to use the win32 thread library instead of pthread (because I'm running on windows). When i build my code, all the calls to boost libraries compile fine, but boost itself is having a compile error. its failing on
boost\thread\pthread\mutex.hpp line 11
cannot open include file: 'pthread.h': No such file or directory
If I could make it use the win32 library, the mutex.hpp (and all the other files) dont call pthread.h
How do I build so that it uses boost\thread\win32 ?
here is the section of my cmakelists.txt
# include boost
set(BOOST_ROOT "E:/boost_1_58_0/boost_1_58_0")
add_definitions( -DBOOST_ALL_NO_LIB )
find_package(Boost COMPONENTS thread system)
if(Boost_FOUND)
message(STATUS "Boost was found, Success!")
# telling it to use win32 threads not pthreads
set(Boost_THREADAPI "win32")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
endif()
CMake comes with a module called FindBoost which i used, and it correctly found the boost directory and set the following
Boost_INCLUDE_DIR
E:/boost_1_58_0/boost_1_58_0/
Boost_LIBRARY_DIR
E:/boost_1_58_0/boost_1_58_0/stage/lib
Boost_SYSTEM_LIBRARY_DEBUG
E:/boost_1_58_0/boost_1_58_0/stage/lib/boost_system-vc100-mt-gd-1_58.lib
Boost_SYSTEM_LIBRARY_RELEASE
E:/boost_1_58_0/boost_1_58_0/stage/lib/boost_system-vc100-mt-1_58.lib
Boost_THREAD_LIBRARY_DEBUG
E:/boost_1_58_0/boost_1_58_0/stage/lib/boost_system-vc100-mt-gd-1_58.lib
Boost_THREAD_LIBRARY_RELEASE
E:/boost_1_58_0/boost_1_58_0/stage/lib/boost_thread-vc100-mt-1_58.lib
visual studio project settings
C/C++ -> General -> Additional Include Directories:
...bunch of my other dependencies
E:\boost_1_58_0\boost_1_58_0
Linker -> General -> Additional Library Directories
E:/boost_1_58_0/boost_1_58_0/stage/lib;E:/boost_1_58_0/boost_1_58_0/stage/lib/$(Configuration);%(AdditionalLibraryDirectories)
Linker -> General -> Link Library Dependencies - No
Linker -> General -> Use LIbrary Dependency Inputs - No
Linker -> Input -> Additional Dependencies:
...bunch of my other .libs
boost_thread.lib
boost_system.lib
I fixed the error but I had try what I call the "dumb" way. The "smart" way didnt work. Smart way was reviewing several times the cmakelists code and the visual studio include library settings. i even did a clean and rebuild boost using b2 and manually set threading=multi and link=static because i thought maybe the library just wasnt built correct.
Finally i gave up and tried the dumb way: I cut and pasted the pthread folder and moved it somewhere else, so that it was no longer in the boost/thread folder, only the win32 folder.
I wish i tried it so long ago, because i didnt think that the compilation error would be due to my project's code, but rather an environment setting in the include and linking. But sure enough i got an error showing that in one of my project's files i was directly trying to include that mutex.hpp from the pthread folder. i didnt write this code (its open source) so i couldnt have exactly known, but still i want to slap myself
#include <boost/thread.hpp>
#include <boost/thread/pthread/mutex.hpp>
changing pthread to win32 made the error go away.
Is there a way to specify in Xcode which binaries to use for compilation? I have recently cross-compiled clang, ld, libtool, etc, and I want to test them.
I am fully aware that I could just do something like:
/Path/To/My/Tools/clang -c file.c
/Path/To/My/Tools/ld file.o -o executable
# or
/Path/To/My/Tools/libtool -static -arch_only x86_64 -o myLib.a *.o
# and so on...
However I am looking for a way to integrate this nicely into Xcode. As my tools should (technically - this is what I want to test) be equivalent to the built-in tools, I don't need to change any of Xcode's default compilation args, etc. I just need to tell it to find the binaries some place other than /usr/bin or somewhere in the ${SDKROOT} or *.xctoochain directories. Is this possible?
There is a project setting for this. In your Xcode project, open the "Project Navigator" and click on the icon for your project. It should show the project settings. In the "Project" section of the project settings, click on the "Build Settings" tab. Type "compiler" into the search field, and it should show you the "Build Options" setting for "Compiler for C/C++/Objective-C". It defaults to Apple LLVM 5.0, but you can change it. Click on "Default (Apple LLVM 5.0)" and select "Other…" It will pop up a text field where you can enter the path to your own tools. It should look like this:
I followed this tutorial : http://tilomitra.com/opencv-on-mac-osx/ to compile OpenCV for Mac OSX in order to use it in XCode 3.2.3
I had no error when compiling openCV. But in XCode I get file was built for unsupported file format which is not the architecture being linked (i386) for each dylib and Symbols not found after.
Any clue ?
steps to compile and run c++ opencv 2.4.4 on mac os x lion 10.7.5 with cmake 2.8.10 and xcode 4.6.1
Having the right tools
download opencv-unix from http://sourceforge.net/projects/opencvlibrary/files/ and untar it wherever
download cmake .dmg from http://www.cmake.org/cmake/resources/software.html and install it
i am assuming you have xcode 4.6 on os x lion which includes the ios sdk 6.1
go to xcode preferences to download and install the Command Line Tools so you have g++ etc.
Use cmake to compile opencv
go to the extracted opencv folder
create a build directory
mkdir build
cd build
cmake -D WITH_TBB=OFF -D BUILD_NEW_PYTHON_SUPPORT=OFF -D BUILD_FAT_JAVA_LIB=OFF -D BUILD_TBB=OFF -D BUILD_EXAMPLES=ON -D CMAKE_CXX_COMPILER=g++ CMAKE_CC_COMPILER=gcc -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_opencv_java=OFF -G "Unix Makefiles" ..
make -j8
sudo make install
from the build folder, go to bin/ and run one of the tests
./opencv_test_stitching
Create your own c++ opencv xcode project
fire up xcode and create a new xcode project
select Command Line Tool for the type of project under os x
open your project's build settings
under Architectures, set Architecture to 64-bit intel. also set Valid Architectures to x86_64
under Build Options, set Compiler for C/C++ to Default Compiler
under Search Paths, set Header Search Paths to /usr/local/include
also under Search Paths, set Library Search Paths to /usr/local/lib
under Apple LLVM compiler 4.2 - Language set C++ Standard Library to libstd++
Add the compiled opencv libraries to your project
go to the Build Phases tab next to Build Settings tab you were in
inside Link Binary With Libraries, click on the + sign and choose Add Other
hit the front slash / on your keyboard and enter /usr/local/lib
hit enter and select the libraries you want to use in your project
make sure you always select libopencv_core.2.4.4.dylib
hit enter and you will see the selected dylibs under your project
write some code
first lets organize the files, right click on your project blueprint icon and select New Group
name the new group opencv or whatever
drag the dylibs and drop them in that group
open main.cpp
copy code from any of the sample tests that came with opencv and paste it here
make sure all the required dylibs are added, for example, if you copied the opencv_test_stitching.cpp code into main.cpp, you will need to add the following libraries in the previous steps
libopencv_core.2.4.4.dylib
libopencv_highgui.2.4.4.dylib
libopencv_stitching.2.4.4.dylib
Cheers.