Thank you for the suggestions, eranif.
Actually, even before you answered, I did (and still do) have an #include statement for the header files declaring the values that give me error messages ("undefined reference to 'x'). I do declare __declspec. I do have paths declared in "Global Settings" for all projects, showing where the library and files reside, and I am sure the files are IN there. I have set up my main program with the sequence of how to compile the projects: the utility dll that everyone depends on first, then the other projects, with the main program last. So I have already tried everything you have suggested, and I still can't get gcc to find my global variables.
I'm sorry. I know you could not have known any of this because I did not post any code. I did not post code because I didn't want to overwhelm you with too much information.
Here is more information about my workspace. Note: here are the real names of my projects, and what they reference.
Code: Select all
Project Name Description
------------ ---------------------------------
dfvint References utilitiesandglobaldata.
dfvproc References utilitiesandglobaldata.
dfvset References utilitiesandglobaldata.
main Main program. References utilitiesandglobaldata, dfvint, dfvproc, and dfvset.
utilitiesandglobaldata Utilities and global data. Does not reference any other project.
"utilitiesandglobaldata" compiles and builds just fine.
I'll give you all the info I think might be helpful for ONE project, dfvint, as an example.
For starters, here is the source code.
H File
Code: Select all
#ifndef DFVINT_H
#define DFVINT_H
#include <windef.h> // This command must appear BEFORE the
// following commands (if applicable):
// #include winnt.h
// #define CALL_TYPE __stdcall
// Make sure functions are exported with C linkage under C++ compilers.
#ifdef __cplusplus
extern "C"
{ // Export the following code with C linkage.
#endif // Notice that this block is still open. It is closed below.
#define DllExport __declspec(dllexport)
#define DllImport __declspec(dllimport)
#define CALL_TYPE __stdcall
#ifndef UNICODE
#define UNICODE
#endif
#include <winbase.h>
#include "gmem.h"
#include "ut.h"
// =============================================================================
// Global Variables
// =============================================================================
extern Int8 dfvint_X;
extern UInt16 dfvint_Y;
extern WORD dfvint_Z;
// =============================================================================
// dfvint_Read_Loop is run from within a thread, which is why its
// declaration is different from the other procedures and functions.
extern DWORD WINAPI dfvint_Thread (void); // our Thread. :-D
extern DllExport long CALL_TYPE dfvint_Initialize (void);
extern DllExport long CALL_TYPE dfvint_Terminate (void);
//====================
#ifdef __cplusplus
} // Export the following code with C linkage.
#endif
#endif // DFVINT_H
C File
Code: Select all
#include <windef.h> // This command must appear BEFORE the
// following commands (if applicable):
// #include winnt.h
// #define CALL_TYPE __stdcall
// Make sure functions are exported with C linkage under C++ compilers.
#ifdef __cplusplus
extern "C"
{ // Export the following code with C linkage.
#endif // Notice that this block is still open. It is closed below.
#define DllExport __declspec(dllexport)
#define DllImport __declspec(dllimport)
#define CALL_TYPE __stdcall
#ifndef UNICODE
#define UNICODE
#endif
#include "printmsgs.h" // Compiler debug print statement controller.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h> // Only including stdarg.h to cover
// definition of va_list in winbase.h.
#include <winbase.h>
#include "gmem.h"
#include "ut.h"
#include "utilitiesandglobaldata.h"
#include "dfvint.h"
// =============================================================================
// Global Variable Declarations. Defined as "extern" in dfvint.h.
// =============================================================================
Int8 dfvint_X;
UInt16 dfvint_Y;
WORD dfvint_Z;
// *****************************************************************************
DWORD WINAPI dfvint_Thread (void) // our Thread. :-D
{ // dfvint_Thread_Proc
return (1); // for now.
} // dfvint_Thread_Proc
// *****************************************************************************
DllExport long CALL_TYPE dfvint_Initialize (void)
{
long rc = TRUE;
// -------------------------------------------------------------------------
ut_Entering (g_STDOUT, "dfvint_Initialize");
ut_Display_Always (g_STDOUT, " dfvint_Initialize: Well, here we are. Now what?");
dfvint_X = -8;
dfvint_Y = 16;
dfvint_Z = 0xFF;
ut_Exiting (g_STDOUT, "dfvint_Initialize");
return (rc);
} // dfvint_Initialize
// *****************************************************************************
DllExport long CALL_TYPE dfvint_Terminate (void)
{
long rc = TRUE;
// -------------------------------------------------------------------------
ut_Entering (g_STDOUT, "dfvint_Terminate");
ut_Display_Always (g_STDOUT, " dfvint_Terminate: Well, here we are. Now what?");
ut_Exiting (g_STDOUT, "dfvint_Terminate");
return (rc);
} // dfvint_Terminate
// -----------------------------------------------------------------------------
#ifdef __cplusplus
} // Export the preceding code with C linkage.
#endif
Here is a screen shot for the dfvint Project Properties:
Kobe--dfvintProjectSettings.jpg
Here is a screen shot showing the build order for main:
Kobe--BuildOrder.jpg
And last, here is the result of "Build Workspace". The resulting file is more than 10K lines long, mostly due to compiler warnings about deprecated function calls. I would sure love to know how to get rid of those messages, without losing other more important messages!
Note: the only dll that this build produced was a utilitiesandglobaldata.dll.
Kobe--BuildResults.txt
I am still stuck. I have tried a lot of different approaches to make the projects dependent on a utility dll to actually link correctly to the utility dll. Nothing I tried worked. I can write up a list of everything I've tried, but that will make my next posting lengthy.
To summarize:
1. The projects referencing the utility project, never find the utility project information that they need.
2. The projects are not compiling in the "Build Order" sequence that I specified for the main program. I did not submit values for the "Build Order" for the other projects. Should I have?
Is there a way to add a "resource" to my utility project? I am using CodeLite 9.2.0 and I don't see where to add a resource. I am going to try adding my utility dll to the project resources. Maybe then, gcc will find the missing declarations.
------------------
Software Versions:
------------------
CodeLite: 9.2.0 Downloaded from web site.
gcc: 4.9.3
tdm-gcc: 5.1.0.3
Windows 7: 6.1
wxCrafter: 2.5
wxWidgets: 3.1.0
Target build: debug
Target platform: 32-bit