Errores del vinculador de DevC ++

I am receiving the following errors in my win32 api code in devc++:

[Linker error] undefined reference to `EnumProcessModules@16' 

[Linker error] undefined reference to `GetModuleFileNameExA@16'

ld returned 1 exit status 

How can I solve this problem? I tried using

#pragma comment(lib, "psapi.lib")

since it was a linker issue but it did not help whatsoever.

preguntado el 10 de marzo de 12 a las 06:03

Your linker is missing the reference to the library in which these functions are defined. What IDE are you using? -

GCC doesn't support #pragma comment. -

What version of Windows SDK you are using? WHat OS version? -

You should probably get rid of Dev-C++, as it's usually the source of most errors. -

Why would you use Dev-C++? Do you like torturing yourself? There are free up-to-date IDEs and compilers which no suck. Why not use one of them? -

2 Respuestas

For future reference I got it to work in CMake as follows, credit goes to Chibueze Opata:

find_library (PSAPI Psapi)

...

add_executable(...)

...

target_link_libraries(Basic -lpsapi)

Respondido el 05 de diciembre de 18 a las 15:12

Link with the library that provides the missing functions.

As mentioned in the question comments, g++ (which most likely is the compiler that you’re using with DevC++) does unfortunately not support #pragma comment.

Also, as mentioned in the question comments, DevC++ is a rather outdated and ungood IDE. Since you are using Windows, try out e.g. Código :: Bloques IDE for the g++ compiler, or Microsoft’s Visual C ++ Express IDE for Visual C++. And with the latter you can use the #pragma, if you want…

respondido 10 mar '12, 11:03

The right answer is to add -lpsapi to the linker options. - Chibueze Opata

@ChibuezeOpata: no, that's not the "right" answer at all; it is of negative utility. you might benefit from exploring "Give a man a fish". or perhaps not, i don't know. - Saludos y hth. - Alf

Sí, we can agree to disagree when you put any of your suggestions on a USB. - Chibueze Opata

@ChibuezeOpata: I guess you're the ignorante downvoter. Jeez. Could you not think of anything better to do than to vandalize a perfectly good answer and then downvote it. - Saludos y hth. - Alf

Your answer is not perfectly good. Kindly include the actual answer with your personal suggestion and I will revise my downvote. Nothing of what you mentioned in your answer solves the problem neither is DevCPP so bad or 'ungood'. - Chibueze Opata

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.