views:

106

answers:

0

Original Question

While trying to compile the example code from 'Example C Program: Using CryptProtectData' I ran into a roadblock; The linker cannot find CryptUnprotectData.

Here is the console output:

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\test\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\test\Makefile.win" all
gcc.exe main.o  -o "Project1.exe" -L"C:/Dev-Cpp/lib" -l crypt32  

main.o(.text+0xcb):main.c: undefined reference to `CryptProtectData'
main.o(.text+0x121):main.c: undefined reference to `CryptUnprotectData'
collect2: ld returned 1 exit status

make.exe: *** [Project1.exe] Error 1

Execution terminated

Edit: Fixed

I am putting the steps I used to fix this so others will find it later.

The problem is Dev-Cpp doesn't include the newest version of the MinGW w32api

Download the newest version of MinGW-w32api.


Backup originals:

$ tar cvvzf include-lib-backup.tar.gz include/ lib/

Extract w32api over old versions:

$ tar xf w32api-3.14-mingw32-dev.tar.gz

And now:

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\test\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\test\Makefile.win" all
gcc.exe -c main.c -o main.o -I"C:/Dev-Cpp/include"   

gcc.exe main.o  -o "Project1.exe" -L"C:/Dev-Cpp/lib" -l crypt32  

Execution terminated
Compilation successful