Re: [Anjuta-list] making SDL available to an Anjuta C++ project



Hi Kevin,

kevinfishburne a écrit :
but am not
sure why I have to start the project as a "Generic C" project instead of a
"Generic C++" project.

Both should work

Starting it as a C++ project causes errors like
main.cc:8: undefined reference to 'SDL_Init'.

I think it's because the SDL library is not linked in your project. How have you added the SDL library ? In the C page, there is SDL project that add the SDL library correctly. But, I think this SDL project doesn't exist in C++ page.

Interestingly when creating a
C project it has the option "Add C++ support".

This just add a check for a c++ compiler in the configure script.

I'm assuming the
differences, whatever they are, are stored in the actual Anjuta project
file, as all the flags, modules, etc. accessible through the GUI seem to be
identical between C and C++ projects.

There isn't such think like an anjuta project file. There is *.anjuta file and a .anjuta directory in your project directory, but they store only user preferences, like size of windows, plugins loaded, last files open and so on. You can look in them, they are all ascii files.

Anjuta uses the standard autotools format: configure.in or configure.ac, and Makefile.am in all project directories. You can work on a project with or without Anjuta without loosing anything. On the other hand, the autotools stuff is a bit complex and the Anjuta GUI support is only partial.

I'm not sure, that you can easily add a library with the GUI. But you can do it quite easily by hand for sdl you can:

in configure.ac or configure.in (it's the same thing) add the following line:
	PKG_CHECK_MODULES (SDL, sdl)
The first SDL is an user defined name that will be used later, and sdl is the name of a library known by pkg-config

in Makefile.am add:
	AM_CFLAGS = $(SDL_CFLAGS)
	my_program_LDADD = $(SDL_LIBS)

AM_CFLAGS and my_program_LDADD are make variables those should be already defined in your Makefile.am. You can add $(SDL_CFLAGS) and $(SDL_LIBS) on the same line or on a line below if you end the previous line with \. This backslash means: do not take in account the end of the line.

_CFLAGS and _LIBS are predefined values, the SDL prefix is the user defined name that you have written in configure.in|ac.

my_program is the name of you program.


This is just a quick advice, to get a better understanding of all this, you need to read some documentation about autotools. I think it's not that complex and quite powerful.


I also couldn't find any include files
in one that weren't in the other.

You need to look in Makefile.am and configure.ac|in files which are part of your program sources files, like *.c.

Regards,

Sébastien




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]