No target declared Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

No target declared

Post by drummerp »

I'm using Code::Blocks to compile a program using the wxWidgets library on a Debian system. I downloaded the .tar.gz, then used ./configure, make, and make install to install the files. In my project's build options, I gave the compiler links to "/usr/local/include/wx-2.8" and "/usr/local/lib/wx/include/x11univ-ansi-debug-static-2.8/" which contain the include files and the "wx/setup.h" file, respectively. It seems that I did everything exactly as I was supposed to, but yet when I try to compile, I get many errors, the most prominent of which (which seems to be causing all the others) is
/usr/local/include/wx-2.8/wx/defs.h | 42 | error: #error "No Target! You should use wx-config program for compilation flags!"

Please help. I can't figure out why it would be saying this. I gave configure the --with-x11 flag, which means that __wxX11__ should be defined, right? But the general area of the code says

#ifdef __cplusplus
/* Make sure the environment is set correctly */
# if defined(__WXMSW__) && defined(__X__)
# error "Target can't be both X and Windows"
# elif defined(__WXMSW__) && defined(__PALMOS__)
# error "Target can't be both PalmOS and Windows"
# elif !defined(__WXMOTIF__) && \
!defined(__WXMSW__) && \
!defined(__WXPALMOS__)&& \
!defined(__WXGTK__) && \
!defined(__WXPM__) && \
!defined(__WXMAC__) && \
!defined(__WXCOCOA__) && \
!defined(__X__) && \
!defined(__WXMGL__) && \
!defined(__WXDFB__) && \
!defined(__WXX11__) && \
wxUSE_GUI
# ifdef __UNIX__
# error "No Target! You should use wx-config program for compilation flags!"
# else /* !Unix */
# error "No Target! You should use supplied makefiles for compilation!"
# endif /* Unix/!Unix */
# endif
#endif /*__cplusplus*/

which would imply it doesn't recognise __WXX11__ as having been defined. Any help is appreciated. I have already run both wx-config -libs and wx-config -cxxflags.
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Post by briceandre »

Under linux, you should probably define __WXX11__ or __WXGTK__, depending on how you compiled wxWidgets.

If you have a full install of wxWidgets, you can use the tool wx-config which will help you find proper flags. You can test something like wx-config -cpp-flags, if I remember correctly.

But, first of all, you should really read a tuto on how to compile a wxWidgets project with codeblocks, because, if you do not know how to do, you willl probably have other problems...
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,
I gave configure the --with-x11 flag
Why? The wxX11 port of wxWidgets is incomplete and little used. Unless you have a very good reason, on Linux you should use wxGTK.

Maybe you have special requirements. But if not, I suggest that you first uninstall your current build; then download the wxGTK tarball (unless you already have the wxWidgets one that can build all of the ports). Then (following the instructions) create a subdirectory of the source dir to do the actual build:

Code: Select all

mkdir urel
cd urel
../configure --with-gtk --enable-unicode
make && make install
(You could also add --enable-debug; I always do).

You can test that you have a successful build by doing, in a terminal:
wx-config --list
The compilation and link data can be seen by:
wx-config --cxxflags
wx-config --libs

Those are the important entries in the C::B configuration; you'll probably have to wrap them in backticks or similar to make them be executed there.

Regards,

David
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

DavidHart wrote:Hi,
I gave configure the --with-x11 flag
Why? The wxX11 port of wxWidgets is incomplete and little used. Unless you have a very good reason, on Linux you should use wxGTK.

Maybe you have special requirements. But if not, I suggest that you first uninstall your current build; then download the wxGTK tarball (unless you already have the wxWidgets one that can build all of the ports). Then (following the instructions) create a subdirectory of the source dir to do the actual build:

Code: Select all

mkdir urel
cd urel
../configure --with-gtk --enable-unicode
make && make install
(You could also add --enable-debug; I always do).

You can test that you have a successful build by doing, in a terminal:
wx-config --list
The compilation and link data can be seen by:
wx-config --cxxflags
wx-config --libs

Those are the important entries in the C::B configuration; you'll probably have to wrap them in backticks or similar to make them be executed there.

Regards,

David
So it's not really multi-platform. If that is true, how does Code::Blocks work so well on my system, if it is built on a wxWidgets system? Is GTK+ the only alternative Linux windowing system, or is it possible mine uses another one besides X11?

Also, another somewhat related question: Can I build other X11 platforms from Linux? If so, can I just package that one with my program and send it to another computer that has that platform for building?
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

Also, for the wx-config, the --list option gives me
"
Default config is x11univ-ansi-debug-static-2.8

Default config will be used for output"

The --cxxflags option gives me
"-I/usr/local/lib/wx/include/x11univ-ansi-debug-static-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_IODBC_ -D__WXDEBUG__ -D__WXUNIVERSAL__ -D__WXX11__ -pthread -fpermissive -fno-rtti -fno-exceptions"

The --libs option gives me
"-L/usr/local/lib -pthread /usr/local/lib/libwx_x11univd-2.8.a -lX11 -lXext -lXinerama -lSM -lpng -lz -ljpeg -lwxodbcd-2.8 -lwxtiffd-2.8 -lz -ldl -lm"
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

So it's not really multi-platform.
Why do you say that? wx works on the three main platforms, plus various others, using native widgets wherever possible so as to look and behave as natively as possible. On Linux it uses the gtk toolkit (there's also a Qt port beginning).
how does Code::Blocks work so well on my system
I haven't looked at its code, but almost certainly by being built using wxGTK. If on your system it doesn't look especially gtk-ish, that's likely to be due to gtk-qt-engine.
Also, for the wx-config, the --list option gives me
//snip
That's fine, if you want a wxX11 ansi debug static build. You just need to put those commands in the correct place inside C::B.
Also, another somewhat related question: Can I build other X11 platforms from Linux? If so, can I just package that one with my program and send it to another computer that has that platform for building?
That's a FAQ, and the answer is basically no.

You can create a source package and expect it to build successfully on any platform that wx supports. On Linux, you can create an appropriate binary package e.g. a .deb or .rpm, and expect it to install and run, but only on another computer running the same version of the same distro (and don't forget 32/64 bit issues).

However different Linux distros, and different versions of those distros, will use different libs, or incompatible versions of libs, or store them in different places. So while in the Windows world it's common to supply apps as statically-linked binaries (as winXP is likely to be much the same on different computers), this seldom happens for Linux. Instead, you should distribute a tarball, and/or binaries created on the same distro/version of the target one; just as the different distros do. Those binary packages can 'depend' on that distro's wxgtk lib package, so there's no need to distribute wxGTK too.
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

Okay, so I tried to uninstall the x11 library and install a wxGTK version. I got this when using 'make':

./src/gtk/toplevel.cpp: In function ‘void wxAddAccelerators(wxList&, wxMenu*)’:
./src/gtk/toplevel.cpp:750: error: incomplete type ‘wxAcceleratorEntry’ used in nested name specifier
./src/gtk/toplevel.cpp:753: error: invalid use of incomplete type ‘struct wxAcceleratorEntry’
./include/wx/menuitem.h:29: error: forward declaration of ‘struct wxAcceleratorEntry’
./src/gtk/toplevel.cpp:753: error: invalid use of incomplete type ‘struct wxAcceleratorEntry’
./include/wx/menuitem.h:29: error: forward declaration of ‘struct wxAcceleratorEntry’
./src/gtk/toplevel.cpp:753: error: invalid use of incomplete type ‘struct wxAcceleratorEntry’
./include/wx/menuitem.h:29: error: forward declaration of ‘struct wxAcceleratorEntry’
./src/gtk/toplevel.cpp: At global scope:
./src/gtk/toplevel.cpp:762: error: ‘wxAcceleratorTable’ does not name a type
./src/gtk/toplevel.cpp: In member function ‘virtual bool wxTopLevelWindowGTK::ShowFullScreen(bool, long int)’:
./src/gtk/toplevel.cpp:806: error: ‘wxAcceleratorTable’ was not declared in this scope
./src/gtk/toplevel.cpp:806: error: expected `;' before ‘table’
./src/gtk/toplevel.cpp:807: error: ‘table’ was not declared in this scope
./src/gtk/toplevel.cpp:808: error: ‘SetAcceleratorTable’ was not declared in this scope

I've tried disabling accelerators, to no avail.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Which tarball did you use? Are you building in a subdirectory, as I suggested? What options did you use in 'configure'? Did 'configure' complete without errors?
I've tried disabling accelerators, to no avail.
No need. wxGTK should compile; if it doesn't, there's something more serious wrong than just accelerators.
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

DavidHart wrote:Which tarball did you use? Are you building in a subdirectory, as I suggested? What options did you use in 'configure'? Did 'configure' complete without errors?
I've tried disabling accelerators, to no avail.
No need. wxGTK should compile; if it doesn't, there's something more serious wrong than just accelerators.
The wxAll 2.8.11 tar.gz file on the downloads page.

I am not building in a subdirectory. I don't follow what you mean? Just create a new directory, and pass some parameter to make to have it do it in that directory, or copy over the source code files for that version and compile it that way? I'm sorry, I'm new to Linux and usually don't compile source-code (mainly because I didn't need to until I started using Linux).

To configure I passed
./configure --with-gtk=2 --disable-shared --enable-monolithic --enable-unicode --enable-no_exceptions --enable-debug_flag --with-odbc --disable-resources --disable-dnd --disable-serial --disable-validators --with-opengl --disable-richtext

Configure did work with no errors. So I don't believe it to be an error with my makefiles, though it could be.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

I am not building in a subdirectory. I don't follow what you mean?
See my first post in this thread.

I don't know why, but some people report compile errors when they don't use a subdir. Others have no problem :/ . It's always a good idea, though, as it separates your .o files from the source, and makes it easy for multiple builds to co-exist.
To configure I passed
./configure --with-gtk=2 --disable-shared --enable-monolithic --enable-unicode --enable-no_exceptions --enable-debug_flag --with-odbc --disable-resources --disable-dnd --disable-serial --disable-validators --with-opengl --disable-richtext
There are many possible options to 'configure'; therefore a large number of possible combinations. As a result of this, almost all combinations will be untested.

I suggest you try again, in a subdir, without the unnecessary 'disable' options: --disable-resources --disable-dnd --disable-serial --disable-validators --disable-richtext. There's also little reason to use --enable-monolithic in wxGTK.
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

Last time I tried to build, when I was doing X11 (though that may have been the problem), I got errors from the richtext library, so I disabled richtext and the errors went away. I'll try that and see if it helps.
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

Okay, I built it in a subdirectory and got rid of the "unnecessary disables", now I get this:

../src/common/db.cpp: In member function ‘bool wxDb::Open(const wxString&, void*, bool)’:
../src/common/db.cpp:866: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘3’ to ‘RETCODE SQLDriverConnect(void*, void*, UCHAR*, SWORD, UCHAR*, SWORD, SWORD*, UWORD)’
../src/common/db.cpp: In member function ‘bool wxDb::Open(const wxString&, const wxString&, const wxString&, bool)’:
../src/common/db.cpp:911: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘2’ to ‘RETCODE SQLConnect(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp: In member function ‘bool wxDb::Open(wxDb*)’:
../src/common/db.cpp:971: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘3’ to ‘RETCODE SQLDriverConnect(void*, void*, UCHAR*, SWORD, UCHAR*, SWORD, SWORD*, UWORD)’
../src/common/db.cpp:986: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘2’ to ‘RETCODE SQLConnect(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp: In member function ‘bool wxDb::getDataTypeInfo(SWORD, wxDbSqlTypeInfo&)’:
../src/common/db.cpp:1669: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘bool wxDb::DispAllErrors(void*, void*, void*)’:
../src/common/db.cpp:1836: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLError(void*, void*, void*, UCHAR*, SDWORD*, UCHAR*, SWORD, SWORD*)’
../src/common/db.cpp: In member function ‘bool wxDb::GetNextError(void*, void*, void*)’:
../src/common/db.cpp:1864: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLError(void*, void*, void*, UCHAR*, SDWORD*, UCHAR*, SWORD, SWORD*)’
../src/common/db.cpp: In member function ‘bool wxDb::DropView(const wxString&)’:
../src/common/db.cpp:2222: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘2’ to ‘RETCODE SQLExecDirect(void*, UCHAR*, SDWORD)’
../src/common/db.cpp: In member function ‘bool wxDb::ExecSql(const wxString&)’:
../src/common/db.cpp:2255: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘2’ to ‘RETCODE SQLExecDirect(void*, UCHAR*, SDWORD)’
../src/common/db.cpp: In member function ‘bool wxDb::GetData(UWORD, SWORD, void*, SDWORD, SQLINTEGER*)’:
../src/common/db.cpp:2391: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘int wxDb::GetKeyFields(const wxString&, wxDbColInf*, UWORD)’:
../src/common/db.cpp:2436: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLPrimaryKeys(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2447: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:2466: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLForeignKeys(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2479: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:2512: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘12’ to ‘RETCODE SQLForeignKeys(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2524: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘wxDbColInf* wxDb::GetColumns(wxChar**, const wxChar*)’:
../src/common/db.cpp:2632: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2640: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2660: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘wxDbColInf* wxDb::GetColumns(const wxString&, UWORD*, const wxChar*)’:
../src/common/db.cpp:2788: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2796: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:2818: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘int wxDb::GetColumnCount(const wxString&, const wxChar*)’:
../src/common/db.cpp:3295: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:3303: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp: In member function ‘wxDbInf* wxDb::GetCatalog(const wxChar*)’:
../src/common/db.cpp:3388: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLTables(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:3413: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3426: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘bool wxDb::Catalog(const wxChar*, const wxString&)’:
../src/common/db.cpp:3495: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLColumns(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:3522: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In member function ‘bool wxDb::TableExists(const wxString&, const wxChar*, const wxString&)’:
../src/common/db.cpp:3630: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLTables(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:3638: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLTables(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp: In member function ‘bool wxDb::TablePrivileges(const wxString&, const wxString&, const wxChar*, const wxChar*, const wxString&)’:
../src/common/db.cpp:3697: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘4’ to ‘RETCODE SQLTablePrivileges(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:3704: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘6’ to ‘RETCODE SQLTablePrivileges(void*, UCHAR*, SWORD, UCHAR*, SWORD, UCHAR*, SWORD)’
../src/common/db.cpp:3718: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3721: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3724: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3727: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3730: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3733: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp:3736: error: ‘SQL_C_WCHAR’ was not declared in this scope
../src/common/db.cpp: In function ‘bool wxDbGetDataSource(void*, wxChar*, SWORD, wxChar*, SWORD, UWORD)’:
../src/common/db.cpp:4472: error: cannot convert ‘SQLTCHAR*’ to ‘UCHAR*’ for argument ‘3’ to ‘RETCODE SQLDataSources(void*, UWORD, UCHAR*, SWORD, SWORD*, UCHAR*, SWORD, SWORD*)’
make: *** [odbclib_db.o] Error 1
drummerp
Knows some wx things
Knows some wx things
Posts: 36
Joined: Sat Dec 25, 2010 10:26 pm

Post by drummerp »

Well, I changed --with-odbc to --without-odbc and it worked, but not necessarily how I would have liked it...
bayn
In need of some credit
In need of some credit
Posts: 2
Joined: Sat Oct 27, 2018 12:27 pm

Re: No target declared

Post by bayn »

Hello,

I'm using Code:: Blocks on a Mac OS system and built wxWidgets 3.0.4 like dynamic linking:

cd wxWidgets
mkdir build-mac-os-x
cd build-mac-os-x
../configure --with-macosx-version-min=10.14 --enable-unicode --prefix="$(pwd)"
make

When I'm building my project I see "No Target! You should use wx-config program for compilation flags!"
I'm define __WXOSX_COCOA__ and __WXOSX_CARBON__ and see warning: option -s is obsolete and being ignored
Which should I define?
Post Reply