0

I need to compile an AES C source code published from MIT university on Windows 7 platform with GCC. At first I got some "missing file" errors, and now that I solved all of them, I receive a linker error "undefined reference to WinMain16".

I am using CodeBlocks.

What I did:

  • copied the aes.c code into new project with codeblocks
  • copied needed header files
  • compiled the aes.c file

What could possibly be the problem?

LSerni
  • 55,617
  • 10
  • 65
  • 107
Mousa Farajallah
  • 167
  • 1
  • 1
  • 11

1 Answers1

0

The code you compiled is probably just a library, exporting functions such as aes_encrypt().

To be able to compile it into an executable, you need to tell the library to actually do something, like here (just to get the idea; that code probably uses a different library).

Libraries are often supplied with "test files", try checking the MIT library bundle.

Try also looking for AES implementations using that library.

Update

The source code you cite has a main() function defined conditionally, so you need to define TEST in order for it to be compiled in, and you need to compile a console application, not a GUI Windows application. Windows GUI application require a WinMain() function, while console apps use a main() function.

Community
  • 1
  • 1
LSerni
  • 55,617
  • 10
  • 65
  • 107
  • Thanks but the file aes.c contains main function is listed on http://stuff.mit.edu/afs/sipb/project/vlcplayer/old/src/ffmpeg/libavutil/ – Mousa Farajallah Nov 25 '12 at 19:42
  • OK, now it's much clearer. You appear to be compiling with the wrong project type settings. See updated answer. – LSerni Nov 26 '12 at 00:13
  • The answer you are commenting. I added an 'Update' section. I also imported that file (and the others .c and .h files), and set Code::Blocks project to 'console application'; I had to remove two assertions and look up Windows `rand()` function, but it did generate an executable. – LSerni Nov 28 '12 at 00:58
  • Dear Iserni, I put the AES.c code inside console application and put the common and aes header files inside the project but what is the TEST that I need to compile the AES.c file when I try to build AES.c file it gives me the same error undefined reference to WinMain@16 – Mousa Farajallah Jan 06 '13 at 15:39
  • If your app requires WinMain, then it is **not** a console application. WinMain is the entry point for a Windows GUI application. As for the TEST, just `#define` TEST in the sources, or set it in the compiler options (for gcc it would be `-DTEST=whatever`; in Code::Blocks it is Project > Build Options > Compiler Settings > #defines). – LSerni Jan 06 '13 at 18:12
  • Dear Iserni can I have your email, I tried to run it with codeblock as console project but not work? – Mousa Farajallah Jan 06 '13 at 18:35