|
From: Philippe de R. <pr...@cl...> - 2001-01-01 22:48:42
|
Hello,
I get the following linker messages when compiling the program below :
c:\dev-c++\projets\wininet\fetchtext\fetchtext1.o: In function `main':
//c/dev-c++/projets/wininet/fetchtext/fetchtext1.cpp:15: undefined =
reference to `InternetOpenA@20'
//c/dev-c++/projets/wininet/fetchtext/fetchtext1.cpp:19: undefined =
reference to `InternetCloseHandle@4'
Can you see anything wrong with my code? What does 'undefined reference' =
mean?
Many thanks.
Philippe de Rochambeau
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Program =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
#include <windows.h>
#include <wininet.h>
#include <iostream>
#include <string>
using namespace std;
#define BUFFLEN 255
int main()
{
string m_strURL =3D "http://localhost";
string m_strResult;
HINTERNET hSession =3D InternetOpen("FetchText1", =
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hSession) {
InternetCloseHandle(hSession);
}
return 0;
=20
|
|
From: Andreas M. <and...@sb...> - 2005-10-17 14:13:19
|
Hallo, I try to build a small application that uses windows funtions that are not in the standard libs but are in the libs of the MS SDK. I did set the path to the libs and also the name of the lib I want to link with, but I get the following log Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Andreas\wtshost\Makefile.win" Führt make... aus make.exe -f "C:\Dev-Cpp\Andreas\wtshost\Makefile.win" all gcc.exe main.o -o "wtshost.exe" -L"C:/Dev-Cpp/lib" -L"C:/Programme/Microsoft Platform SDK/Lib/" -mwindows -l "C:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib" C:\Dev-Cpp\Bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lC:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib collect2: ld returned 1 exit status make.exe: *** [wtshost.exe] Error 1 I am sure the path is OK. I tried with the -L phat and -lWtsApi32.Lib without the full path, but I get the same error. What's wrong in my projec tconfiguration ? Bye Andreas |
|
From: Alfred P. R. <al...@ya...> - 2005-10-17 20:35:11
|
Hi Andreas, The only thing that I can obviously see is the text: -lC:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib As gcc is using the Unix convention for path names, the spaces in the path name will cause a problem. Try single quoting it as -l'C:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib'. If that doesn't work, just physically copy it to the lib folder of dev-cpp. The other possibility is that if you're adding this to the to the linker parameters with the -l, that -l tries to add the prefix lib and suffix .a to the library, making it actually libWtsApi32.Lib.a which won't be found. As an example my use of -lgimp-2.0 in Project Options->Parameters->Linker actually refers to libgimp-2.0.dll.a in the default lib directory. Andreas Moroder <and...@sb...> wrote: Hallo, I try to build a small application that uses windows funtions that are not in the standard libs but are in the libs of the MS SDK. I did set the path to the libs and also the name of the lib I want to link with, but I get the following log Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Andreas\wtshost\Makefile.win" Führt make... aus make.exe -f "C:\Dev-Cpp\Andreas\wtshost\Makefile.win" all gcc.exe main.o -o "wtshost.exe" -L"C:/Dev-Cpp/lib" -L"C:/Programme/Microsoft Platform SDK/Lib/" -mwindows -l "C:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib" C:\Dev-Cpp\Bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lC:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib collect2: ld returned 1 exit status make.exe: *** [wtshost.exe] Error 1 I am sure the path is OK. I tried with the -L phat and -lWtsApi32.Lib without the full path, but I get the same error. What's wrong in my projec tconfiguration ? Bye Andreas ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users Alfred P. Reaud |
|
From: Andreas M. <and...@sb...> - 2005-10-21 12:00:49
|
Alfred P. Reaud schrieb: > Hi Andreas, > > The only thing that I can obviously see is the text: > -lC:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib > > As gcc is using the Unix convention for path names, the spaces in the > path name will cause a problem. Try single quoting it as > -l'C:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib'. If that > doesn't work, just physically copy it to the lib folder of dev-cpp. > > The other possibility is that if you're adding this to the to the linker > parameters with the -l, that -l tries to add the prefix lib and suffix > .a to the library, making it actually libWtsApi32.Lib.a which won't be > found. As an example my use of -lgimp-2.0 in Project > Options->Parameters->Linker actually refers to libgimp-2.0.dll.a in the > default lib directory. Hello Alfred, I copied the file to the lib directory, but now i get this error main.o(.text+0x33):main.c: undefined reference to `WTSEnumerateSessionsA@20' main.o(.text+0x4b):main.c: undefined reference to `WTSFreeMemory@4' collect2: ld returned 1 exit status any hint ? Bye Andreas |
|
From: Blagoja G. <bla...@gm...> - 2005-10-21 12:32:20
|
Hi, I'm not sure, but I think that you must enter path to C:\Programme\Microsoft Platform SDK\Lib and C:\Programme\Microsoft Platform SDK\Include in the Dev-Cpp. You can do this by clicking on the Tools / Compiler Options menu. Go to "Directories" tab and "Libraries" and "C Includes" (or "C++ Includes") sub-tabs. Good luck, Blagoja |
|
From: Blagoja G. <bla...@gm...> - 2005-10-21 12:39:50
|
> Hi, > I'm not sure, but I think that you must enter path to > C:\Programme\Microsoft Platform SDK\Lib > and > C:\Programme\Microsoft Platform SDK\Include > in the Dev-Cpp. You can do this by clicking on the Tools / Compiler > Options menu. Go to "Directories" tab and "Libraries" and "C Includes" > (or "C++ Includes") sub-tabs. > > Good luck, > Blagoja I forget, You can do this also in the Project / Project Options menu. In the "Directories" tab. Blagoja |
|
From: Andreas M. <and...@sb...> - 2005-10-21 12:52:29
|
Blagoja Gjakovski schrieb: >> Hi, >> I'm not sure, but I think that you must enter path to=20 >> C:\Programme\Microsoft Platform SDK\Lib >> and >> C:\Programme\Microsoft Platform SDK\Include >> in the Dev-Cpp. You can do this by clicking on the Tools / Compiler=20 >> Options menu. Go to "Directories" tab and "Libraries" and "C Includes"= =20 >> (or "C++ Includes") sub-tabs. >> >> Good luck, >> Blagoja >=20 >=20 > I forget, > You can do this also in the Project / Project Options menu. > In the "Directories" tab. >=20 > Blagoja >=20 >=20 Hello Blagoja, I had already set the path in my project. Now I did delete it from there=20 and put it into the compiler options. The linker finds the library I have set as parameter in the=20 project/options/parameters/linker ( -lwtsApi32 ) I am sure because if I change this name I get the error that the file=20 was not found Now it continues to tell me that there is a undefined reference to `WTSEnumerateSessionsA@20' even if the function I use is WTSEnumerateSessionsA Does the compiler mangle the names the way that they are different than=20 the icrosoft one ? Is mangling not used only in c++, my project is c Bye Andreas here the output Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Andreas\wtshost\Makefile.win" F=FChrt make... aus make.exe -f "C:\Dev-Cpp\Andreas\wtshost\Makefile.win" all gcc.exe main.o -o "wtshost.exe" -L"C:/Dev-Cpp/lib"=20 -L"C:/Programme/Microsoft Platform SDK/Lib" -mwindows -lwtsApi32 main.o(.text+0x33):main.c: undefined reference to `WTSEnumerateSessionsA@= 20' main.o(.text+0x4b):main.c: undefined reference to `WTSFreeMemory@4' collect2: ld returned 1 exit status make.exe: *** [wtshost.exe] Error 1 Ausf=FChrung beendet |
|
From: Blagoja G. <bla...@gm...> - 2005-10-21 14:22:04
|
Ok, but you must follow this procedure: Insert this Paths in Tools / Compiler Options / Directories / Libraries "C:\Dev-Cpp\lib C:\Programme\Microsoft Platform SDK\Lib" Insert this Paths in Tools / Compiler Options / Directories / C Includes "C:\Dev-Cpp\include C:\Programme\Microsoft Platform SDK\Include" Insert this Paths in Project / Project Options / Directories / Library Directories "C:\Dev-Cpp\lib C:\Programme\Microsoft Platform SDK\Lib" Insert this Paths in Project / Project Options / Directories / Include Directories "C:\Dev-Cpp\include C:\Programme\Microsoft Platform SDK\Include" Insert this Paths in Project / Project Options / Parameters / Linker "C:/Programme/Microsoft Platform SDK/Lib/WtsApi32.Lib" Execute batch file "SetEnv.Cmd" in C:\Programme\Microsoft Platform SDK\ In "main.c" file insert this: #include "WtsApi32.h" or full path #include "C:/Programme/Microsoft Platform SDK/Include/WtsApi32.h" Thats all, Blagoja |
|
From: Elias P. <Eli...@ao...> - 2001-01-01 23:05:20
|
> > Hello, > > I get the following linker messages when compiling the > program below : > > c:\dev-c++\projets\wininet\fetchtext\fetchtext1.o: In > function `main': > c/dev-c++/projets/wininet/fetchtext/fetchtext1.cpp:15: > undefined reference to `InternetOpenA@20' > c/dev-c++/projets/wininet/fetchtext/fetchtext1.cpp:19: > undefined reference to `InternetCloseHandle@4' > > Can you see anything wrong with my code? What does > 'undefined reference' mean? > If your source code is in no project, add it to a new project. Then try adding the following to the "project options/further object files or linker options": -lwininet |