i'm having a problem related to the undefined reference error.
The function below return an error during make like: undefined reference to 'lightpen_enabled'.
Now, all the 3 parameters of this conditional check if (_mouse_enabled && !lightpen_enabled && !sdl_menu_state) are defined into respective file, lightpen.h, uimenu.h and mouse.h, each as follow:
Post the exact error message, which is good practice to start with, someone may see something that you do not.
Check your spelling for "lightpen_enabled". It could be misspelled somewhere you did not notice.
Not all error messages will tell you where the problem is just where it showed up. Many times the actual error is above the line picked as having an error. Or in this case it could be in another file.
Right now I do not see enough of the program to be able to trace "lightpen_enabled" from its original definition to the code above.
You have already compiled this file that implements the void ui_check_mouse_cursor) (and possibly some other translation units. In this file (via include) it is known that somebody else implements the int lightpen_enabled.
Now linker should put the binary together. None of the object files that you have given to the linker does contain the implementation of int lightpen_enabled.
In other words, your build system does not handle all necessary files.
Making all in platform
main.o: In function `main_program':
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/main.c:235: undefined reference to
`core_team'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/main.c:237: undefined reference to
`core_team'
../src/arch/sdl/libarch.a(ui.o): In function `ui_check_mouse_cursor':
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/ui.c:496: undefined
reference to `lightpen_enabled'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/ui.c:496: undefined
reference to `lightpen_enabled'
../src/arch/sdl/libarch.a(lightpendrv.o): In function `sdl_lightpen_update':
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/lightpendrv.c:47:
undefined reference to `lightpen_enabled'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/lightpendrv.c:47:
undefined reference to `lightpen_enabled'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/lightpendrv.c:95:
undefined reference to `lightpen_update'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/lightpendrv.c:95:
undefined reference to `lightpen_update'
../src/arch/sdl/libarch.a(menu_help.o): In function `about_callback':
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/menu_help.c:368: undefined
reference to `core_team'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/menu_help.c:368: undefined
reference to `core_team'
../src/arch/sdl/libarch.a(menu_help.o): In function `contrib_convert':
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/menu_help.c:137: undefined
reference to `info_contrib_text'
/AOS/Software/Development/Vice
31/vice-am-31/vice-3.1/src/arch/sdl/menu_help.c:137: undefined
reference to `info_contrib_text'
gmake[3]: *** [vsid] Error 1
gmake[2]: *** [all-recursive] Error 1
bin:gmake[1]: *** [all] Error 2
gmake: *** [all-recursive] Error 1
3.AOS:Software/Development/Vice 31/vice-am-31/vice-3.1>
Where do you actually define lightpen_enabled and all those other global variables?
You've showed us where you declare them (as externs), but you haven't shown us where you actually define them. There needs to be a single definition somewhere.
Now, all the 3 parameters of this conditional check if (_mouse_enabled && !lightpen_enabled && !sdl_menu_state) are defined into respective file, lightpen.h, uimenu.h and mouse.h, each as follow:
your build system does not handle all necessary files.
I think this could also mean you don’t list all the source files in your compilation command.
Could you please check if they are all there? Something like: gcc ... mouse.c lightpen.c sdl_menu_state.c main.c ... -o myprog.exe
Also, is your code entirely in C or is it a mixture of C and C++? In that case, maybe you need the extern C declaration.
Configure files and makefiles are huge. I will try to search into those, but i suspect that compilations of various files is made using some sort of wildcard.
@Enoizat
The lowest level of compiling is to manually call gcc/g++ with some options.
The next level is to write a Makefile manually and run make/gmake/nmake.
The next level is to use some tool (e.g. GNU autotools, cmake, qmake) that automatically writes the Makefile(s) for you from "project config". These tools are likely to have a method to generate the initial config.
The next level is an IDE, where one can clickety clack, GUI crap the project config, makefile generation, compilation, etc. Due to the nature of GUI, wildcards are highly unlikely in IDE.