How to Specify a DLL in a Plain Vanilla C Program
Posted: Tue Apr 05, 2016 9:27 pm
I am trying to compile a plain vanilla C program in CodeLite, using TDM-GCC as the compiler. I'm making a Release (not Debug) build.
The compiler is giving me an error I don't know how to fix, and I hope one of you can help me fix it.
Here is my main program.
This program calls ut_Calculate_Sum and ut_Calculate_Average in libSimpleUtil.dll
To set the make settings, I went to Settings, Build Settings, and clicked on "gnu gcc," and clicked on the "Tools" tab. I changed the "-j 4" (which gave me errors) to C:\TDM-GCC-32\bin\mingw32-make.exe and clicked OK.
To tell the compiler where to find libSimpleUtil.dll, I right-clicked on the Project name, clicked Settings, clicked Linker, and clicked in the Libraries box. I navigated to F:\Prototypes_CPP\TestingReadingNetbeansDLL\DLLCaller\Release, the folder in which I thought the EXE would be built.
But when I compile, I get the following error message.
How do I fix this?
The compiler is giving me an error I don't know how to fix, and I hope one of you can help me fix it.
Here is my main program.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include "datatypes.h"
#include "printmsgs.h"
#include "ut-simple.h"
int main(int argc, char **argv)
{
int Ave = 0;
long Sum = 0;
int N1 = 30;
int N2 = 50;
printf("Entering TestingReadingNetbeansDLL main.\n");
printf("N1 = %12d \n", N1);
printf("N2 = + %12d \n", N2);
printf(" ---- \n");
Sum = ut_Calculate_Sum (N1, N2);
printf(" %12ld = sum \n\n", Sum);
Ave = ut_Calculate_Average (N1, N2);
printf(" %12d = Average\n\n", Ave);
printf("Done!\n");
return 0;
}
To set the make settings, I went to Settings, Build Settings, and clicked on "gnu gcc," and clicked on the "Tools" tab. I changed the "-j 4" (which gave me errors) to C:\TDM-GCC-32\bin\mingw32-make.exe and clicked OK.
To tell the compiler where to find libSimpleUtil.dll, I right-clicked on the Project name, clicked Settings, clicked Linker, and clicked in the Libraries box. I navigated to F:\Prototypes_CPP\TestingReadingNetbeansDLL\DLLCaller\Release, the folder in which I thought the EXE would be built.
But when I compile, I get the following error message.
Code: Select all
C:\Windows\system32\cmd.exe /C C:/TDM-GCC-32/bin/mingw32-make.exe -e -f Makefile
"----------Building project:[ DLLCaller - Release ]----------"
mingw32-make.exe[1]: Entering directory 'F:/Prototypes_CPP/TestingReadingNetbeansDLL/DLLCaller'
gcc -o ./Release/DLLCaller @"DLLCaller.txt" -L. -lF:/Prototypes_CPP/TestingReadingNetbeansDLL/DLLCaller/Release
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lF:/Prototypes_CPP/TestingReadingNetbeansDLL/DLLCaller/Release
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [Release/DLLCaller] Error 1
mingw32-make.exe: *** [All] Error 2
DLLCaller.mk:80: recipe for target 'Release/DLLCaller' failed
mingw32-make.exe[1]: Leaving directory 'F:/Prototypes_CPP/TestingReadingNetbeansDLL/DLLCaller'
Makefile:4: recipe for target 'All' failed
====0 errors, 0 warnings====