Author Topic: Making and using dll's in c++ (code::blocks) gcc  (Read 9154 times)

0 Members and 1 Guest are viewing this topic.

xteraco

  • Guest
ok, heres a good tutorial that i think belongs in the c++ section here... basically its a extremely simple program that shows how to make a dll, and then make an exe that can read from it... pretty simple :) 

-enjoy

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Making and using dll's in c++ (code::blocks) gcc
« Reply #1 on: July 05, 2006 »
Cheers dude :) + Karma!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: Making and using dll's in c++ (code::blocks) gcc
« Reply #2 on: January 05, 2007 »
I've tryed to learn c++ before but gave up since I diddn't know anyone hwo knew the language and now i tryed this...

I get the error when tyying to compile it
[Linker error] undefined reference to `WinMain@16'

Edit:
I tryed some other code and got the same error

Edit:
This may help

Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\david1.DAVID\Desktop\paul\blitz userlib tests\dono\c++\tutirial\dll\dll.cpp" -o "C:\Documents and Settings\david1.DAVID\Desktop\paul\blitz userlib tests\dono\c++\tutirial\dll\dll.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Dev-Cpp\lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status

Execution terminated
« Last Edit: January 05, 2007 by Paul »
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Making and using dll's in c++ (code::blocks) gcc
« Reply #3 on: January 05, 2007 »
Depends what kind of program you're trying to write.  If you're writing a normal command prompt program, the execution of your code begins with a function called main().  If you're writing a Windows program then your code begins with WinMain().  And if you're writing a DLL, your code gets called at DllMain().
So, C and C++ command line programs look like this
Code: [Select]
int main(void)
{
  //your code goes here
  return 0;
}
and a Windows app looks like this
Code: [Select]
#include <windows.h>
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  //your code goes here
  return 0;
}

I think the problem is you've got your dev C settings wrong, and you're trying to build a command line program as a Windows program, and it thinks that WinMain() is missing.

Jim
Challenge Trophies Won: