Using WxWidgets with Eclipse for C++ - eclipse

I installed wxWidgets and then followed the instructions to make it with MSYS. After it was done, I copied a sample from a site and put it on a project in eclipse. The code was:
#include <wx/string.h>
int main(int argc, char **argv)
{
wxPuts(wxT("A wxWidgets console application"));
}
But when I compile I get this error:
**** Build of configuration Debug for project test2 ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\test2.o ..\src\test2.cpp
..\src\test2.cpp:9:23: wx/string.h: No such file or directory
..\src\test2.cpp: In function `int main(int, char**)':
..\src\test2.cpp:13: error: `wxT' was not declared in this scope
..\src\test2.cpp:13: error: `wxPuts' was not declared in this scope
..\src\test2.cpp:13: warning: unused variable 'wxT'
..\src\test2.cpp:13: warning: unused variable 'wxPuts'
Build error occurred, build is stopped
Time consumed: 78 ms.
What did I do wrong?
I edited the settings but I still get this.
There is no -I still..
**** Build of configuration Debug for project Wx1 ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\simple.o ..\src\simple.cpp
In file included from ..\src\simple.cpp:1:
..\src\simple.h:1:19: wx/wx.h: No such file or directory
In file included from ..\src\simple.cpp:1:
..\src\simple.h:4: error: expected class-name before '{' token
..\src\simple.h:6: error: expected `,' or `...' before '&' token
..\src\simple.h:6: error: ISO C++ forbids declaration of `wxString' with no type
..\src\simple.cpp:3: error: expected `,' or `...' before '&' token
..\src\simple.cpp:4: error: ISO C++ forbids declaration of `wxString' with no type
..\src\simple.cpp: In constructor `Simple::Simple(int)':
..\src\simple.cpp:4: error: class `Simple' does not have any field named `wxFrame'
..\src\simple.cpp:4: error: `NULL' was not declared in this scope
..\src\simple.cpp:4: error: `wxID_ANY' was not declared in this scope
..\src\simple.cpp:4: error: `title' was not declared in this scope
..\src\simple.cpp:4: error: `wxDefaultPosition' was not declared in this scope
..\src\simple.cpp:4: error: `wxSize' was not declared in this scope
..\src\simple.cpp:6: error: `Centre' was not declared in this scope
..\src\simple.cpp:6: warning: unused variable 'Centre'
..\src\simple.cpp:4: warning: unused variable 'NULL'
..\src\simple.cpp:4: warning: unused variable 'wxID_ANY'
..\src\simple.cpp:4: warning: unused variable 'title'
..\src\simple.cpp:4: warning: unused variable 'wxDefaultPosition'
..\src\simple.cpp:4: warning: unused variable 'wxSize'
Build error occurred, build is stopped
Time consumed: 63 ms.
Here is a screenshot
screenshot http://imgkk.com/i/aRjvDe.jpg
What am I doing wrong?

Seems like you didn't set the correct include directories to find the wx headers (There is no -I... on the compiler command line).
You could add include directories in the project settings of a CDT project under C++->Settings->GNU C++->Include directories (or similar I don't have Eclipse running at the moment so the names way vary).
EDIT:
You have changed the "GCC Assembler" include paths. Since you don't program assembler this part isn't used. You need to edit the include paths in the "GCC C++ Compiler" path!

Perhaps the guide here might help you, as you have already built this library I guess you only read for the section titled Verification that wxWidgets Libraries Are Working onwards.

Related

fatal error: could not build module 'Darwin'

I'm new to vapor and I just installed in on MacOS, I'm getting following error when I build it. Does anyone know how to fix it? I've searched but most of the solution mentioned are for iOS rather than MacOS.
While building module 'Darwin' imported from /Users/imac1/ROOT/Vapor/Hello/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h:35:
In file included from <module-includes>:357:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/ncurses.h:141:
/opt/local/include/unctrl.h:60:63: error: unknown type name 'SCREEN'
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
/opt/local/include/unctrl.h:60:53: error: function cannot return function type 'char *(int *, chtype)' (aka 'char *(int *, unsigned int)')
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
/opt/local/include/unctrl.h:60:54: error: a parameter list without types is only allowed in a function definition
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
In file included from /Users/imac1/ROOT/Vapor/Hello/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/c_nio_http_parser.c:24:
/Users/imac1/ROOT/Vapor/Hello/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h:35:10: fatal error: could not build module 'Darwin'
#include <stddef.h>
~~~~~~~~^
4 errors generated.
[0/20] Compiling CNIOHTTPParser c_nio_http_parser.c
[1/20] Compiling CNIOLinux shim.c
[2/20] Compiling CNIOZlib empty.c
[3/20] Compiling CNIOLinux ifaddrs-android.c
[3/20] Compiling CNIOOpenSSL shims.c
[3/20] Compiling CNIOOpenSSL helpers.c
[3/20] Compiling CNIODarwin shim.c
[3/20] Compiling CNIOSHA1 c_nio_sha1.c
Uninstall MacPorts - it installs header files where they shouldn’t be and the compiler uses those header files rather than the ones bundled with Xcode

Using Language standard ISO c++ 98 with MinGW in Eclipse

I want build my c++ project with ISO c++ 98 but when I build I have this in console :
Info: Internal Builder is used for build
g++ -std=c++98 -O0 -g3 -Wall -c -fmessage-length=0 -o "src\ProvaISO98.o" "..\src\ProvaISO98.cpp"
In file included from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\postypes.h:40:0,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\iosfwd:40,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:38,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\src\ProvaISO98.cpp:9:
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:164:11: error: '::vfwscanf' has not been declared
using ::vfwscanf;
^~~~~~~~
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:170:11: error: '::vswscanf' has not been declared
using ::vswscanf;
^~~~~~~~
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:174:11: error: '::vwscanf' has not been declared
using ::vwscanf;
^~~~~~~
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:191:11: error: '::wcstof' has not been declared
using ::wcstof;
^~~~~~
In file included from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_facets.h:39:0,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_ios.h:37,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:44,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\src\ProvaISO98.cpp:9:
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwctype:89:11: error: '::iswblank' has not been declared
using ::iswblank;
With ISO c++ 11 I haven't problem. Maybe I must change option -std=c++98 in -std=gnu++98 but I don't known how to do this.

How are the libraries .h files included

I have successfully generated Objc .m and .h files from my simplistic Dagger-2 code.
https://gist.github.com/OscarRyz/ffd976fcae9acf87dbe1
Now I'm trying to compile those file using j2objcc but the error message says it can't find .h for the the Dagger-2 classes:
j2objcc -c -I. `find app -name *.m`
In file included from app/DaggerSearchComponent.m:10:
./app/SearchInPage_Factory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
app/SearchComponent.m:11:10: fatal error: 'dagger/Component.h' file not found
#include "dagger/Component.h"
^
1 error generated.
In file included from app/SearchInPage_Factory.m:8:
./app/SearchInPage_Factory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
In file included from app/SearchInPage_MembersInjector.m:9:
./app/SearchInPage_MembersInjector.h:10:10: fatal error: 'dagger/MembersInjector.h' file not found
#include "dagger/MembersInjector.h"
^
1 error generated.
app/SearchModule.m:10:10: fatal error: 'dagger/Module.h' file not found
#include "dagger/Module.h"
^
1 error generated.
In file included from app/SearchModule_ProvideHostFactory.m:8:
./app/SearchModule_ProvideHostFactory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
In file included from app/SearchModule_ProvideHttpClientFactory.m:9:
./app/SearchModule_ProvideHttpClientFactory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
Question: Does this means that I need to have the library source code while generating the ObjC code so the .h for those could be generated as well?
Original answer from #tabll
Dagger isn't distributed with j2objc, so you have to build it yourself. To do so (requires Maven, described in the Building J2ObjC wiki):
git clone https://github.com/google/dagger.git
cd dagger
mvn install
j2objc -d build -classpath $J2OBJC_HOME/lib/javax-inject.jar -sourcepath core/src/main/java `find core/src/main/java -name *.java`
cd build
j2objcc -c -I. `find dagger -name *.m`
ar -r libdagger.a *.o
Notes:
Specify J2OBJC_HOME either where your j2objc distribution was unzipped, or if you built j2objc, its dist directory. To test, "ls $J2OBJC_HOME/j2objc" should list the j2objc script.
These instructions generate the macosx architecture, useful when testing. The files need to be recompiled for each architecture you want to use -- the easiest way to do so is to create a static library project in Xcode, add the translated files, then include this project in your app and add it as a dependency of your app.
ar will warn that "libdagger.a(package-info.o) has no symbols", which can be ignored since it doesn't have any symbols.

Rcpp+Eclipse on Mac OS X

I am trying to get started using Rccp and decided to use Eclipse as a development environment since I already use StatEt for R. I am having trouble getting even a simple program to compile and run though, and would appreciate some help!
Briefly I tried to follow the instructions on the blog: http://blog.fellstat.com/?p=170 exactly for setting up Rcpp, RInside and Eclipse, and for the example program. I am running on Mountain Lion, and installed g++ using the command line options in XCode. I think I've faithfully followed all the steps in the blog, but cannot get the program to compile. I think the problem is in the way the header files are included, as indicated from the snippet of the output below. As far as I can tell, line 52 of /usr/include/c++/4.2.1/cstring is an include statement for <string.h> and the compiler includes Rccp/include/string.h instead of the string.h from std that is found earlier on the include path.
I am a novice in C++ so I'd really appreciate some pointers on how to proceed.
-Krishna
16:22:38 **** Incremental Build of configuration Debug for project MyTestRCppPackage ****
Info: Internal Builder is used for build
g++ -DINSIDE -I/Library/Frameworks/R.framework/Versions/2.15/Resources/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include -O0 -g3 -Wall -c -fmessage-length=0 -arch x86_64 -v -o src/main.o ../src/main.cpp
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/cc1plus -quiet -v -I/Library/Frameworks/R.framework/Versions/2.15/Resources/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include -imultilib x86_64 -iprefix /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/ -dD -D__DYNAMIC__ -DINSIDE ../src/main.cpp -fPIC -quiet -dumpbase main.cpp -mmacosx-version-min=10.8.3 -m64 -mtune=core2 -auxbase-strip src/main.o -g3 -O0 -Wall -version -fmessage-length=0 -D__private_extern__=extern -o /var/folders/hc/vqp48jt56_v332kc3dqyf5780000gn/T//ccqdmOKI.s
ignoring nonexistent directory "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
#include "..." search starts here:
#include <...> search starts here:
/Library/Frameworks/R.framework/Versions/2.15/Resources/include
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include
/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include
/usr/include/c++/4.2.1
/usr/include/c++/4.2.1/backward
/usr/local/include
/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
GNU C++ version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) (i686-apple-darwin11)
compiled by GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00).
GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=65536
Compiler executable checksum: b37fef824b01c0a99fb2679acf3b04f1
In file included from /usr/include/c++/4.2.1/cstring:52,
from /usr/include/c++/4.2.1/bits/stl_algobase.h:66,
from /usr/include/c++/4.2.1/memory:53,
from /usr/include/c++/4.2.1/tr1/hashtable:56,
from /usr/include/c++/4.2.1/tr1/unordered_map:37,
from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:158,
from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/RcppCommon.h:26,
from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp.h:27,
from ../src/main.cpp:8:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: 'internal' has not been declared
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: typedef name may not be a nested-name-specifier
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: expected ';' before '<' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:65: error: expected `)' before 'charsxp'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:70: error: expected ',' or '...' before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: expected unqualified-id before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: expected ',' or '...' before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: 'Rcpp::String::String()' cannot be overloaded
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:55: error: with 'Rcpp::String::String()'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:85: error: 'Rcpp::String::String(int)' cannot be overloaded
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:70: error: with 'Rcpp::String::String(int)'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:88: error: expected `)' before 'x'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:89: error: expected `)' before 'x'
There are two entirely separate issues here:
Get all you need for Rcpp installed. OS X aspects should be documented on the relevant page maintained by Simon. If you have the tools, and have Rcpp install, then you should be able to do cppFunction('double nPi(int x) { return x*M_PI; }') which is uses functions supplied with Rcpp to create a callable C++ functions accessible to you as nPi() -- and nPi(2) should return a value.
Your choice of IDE and its settings. This is has little to do with 1. apart from requiring it to work to.
So I would work on 1. and see if I got that sorted out first, and only then turn to 2.
To summarize, the issue I faced was that include files in Rcpp with the sames names as those in std were in conflict. In particular, string.h from Rcpp was being included at a point where string.h from std was the right choice, and, as far as I could tell, this was due to the fact that paths specified via the -I directive are searched prior to the default paths.
I tried many different alternatives to solve this, including removing and re-installing XCode and the associated Command Line tools, as well as installing another g++ compiler using macports. None of these resolved the issue. I then used the -idirafter directive instead of the -I directive for the search path for include files for Rcpp and R. I got this hint from gcc include order broken?. This worked since these directories are now searched after the default paths. This precludes (at least so far!) the possibility that string.h from std and string.h from Rcpp come into conflict.
To get step 5 of http://blog.fellstat.com/?p=170 to work I had to set the -idirafter paths in PKG_CPPFLAGS in the file Makevars.
Thanks to everyone for your suggestions.
You simply have to remove include
/Library/Frameworks/R.framework/Resources/library/Rcpp/include/Rcpp
because it is:
unnecessary, as all R imports are in form <Rcpp/XXX>
causes this issue, as compiler looks for string.h in Rcpp directory (when it shouldn't).

eclipse cdt not seeing header files in project packages?

I am trying to compile a project but I'm getting an error right away that it's not seeing the header files that are in some packages inside the project. Here is a picture, notice that it is not finding the AwarenessMoment.h file, however it is in there.
Here is the output:
**** Build of configuration Debug for project RoyOS ****
make all
Building file: ../src/royos/vision/ImageRecognizer.cpp
Invoking: GCC C++ Compiler
g++ -I/home/igvc/Documents/teamigvc/trunk/RoyOS -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/royos/vision/ImageRecognizer.d" -MT"src/royos/vision/ImageRecognizer.d" -o"src/royos/vision/ImageRecognizer.o" "../src/royos/vision/ImageRecognizer.cpp"
In file included from ../src/royos/vision/ImageRecognizer.cpp:8:0:
../src/royos/vision/ImageRecognizer.h:11:29: fatal error: AwarenessMoment.h: No such file or directory
compilation terminated.
make: *** [src/royos/vision/ImageRecognizer.o] Error 1
Anyone know why it's not seeing these header files?
Thanks
There's definitely something wrong with the include path given to the compiler. The preprocessor can't find the header from the source file you are attempting to compile.
I think you could fix this by replacing
#include "AwarenessMoment.h"
with
#include "../sensor/AwarenessMoment.h"
Either that or alter the compiler include path to include the sensor directory and use:
#include <AwarenessMoment>