Probleme bei DLL-Erstellung und <vector>

  • Thread starter Stefan.Wagenbrenner
  • Start date
S

Stefan.Wagenbrenner

Good morning,

I'm trying to write a dll using Dev Cpp 4. I'm able to compile the
following code, but the linker throws an error and no dll is produced:

#include <stdio.h>
#include <windows.h>
#include <vector>

// ... more code ...

vector<char> charSubstring (char *str, int start, int ende)
{
vector<char> subs;

for (int i=start; i<=ende; i++)
{
subs.push_back(str);
}
}

The linker tells me the following:

$_S_oom_malloc alloc template1iOUi+0x1a):maindll.cpp: undefined
reference to `endl(ostream &)`
$_S_oom_malloc alloc template1iOUi+0x1a):maindll.cpp: undefined
reference to `cerr`
$_S_oom_malloc alloc template1iOUi+0x1a):maindll.cpp: undefined
reference to `ostream::eek:perator<<(char const *)`
gcc exited with status 1

When I use the code above in a "normal" program it works fine. Could
someone tell me what I´m doing wrong?


Thanks in advance

Stefan Wagenbrenner
 
J

Jim Langston

Good morning,

I'm trying to write a dll using Dev Cpp 4. I'm able to compile the
following code, but the linker throws an error and no dll is produced:

#include <stdio.h>
#include <windows.h>
#include <vector>

// ... more code ...

vector<char> charSubstring (char *str, int start, int ende)
{
vector<char> subs;

for (int i=start; i<=ende; i++)
{
subs.push_back(str);
}
}

The linker tells me the following:

$_S_oom_malloc alloc template1iOUi+0x1a):maindll.cpp: undefined
reference to `endl(ostream &)`
$_S_oom_malloc alloc template1iOUi+0x1a):maindll.cpp: undefined
reference to `cerr`
$_S_oom_malloc alloc template1iOUi+0x1a):maindll.cpp: undefined
reference to `ostream::eek:perator<<(char const *)`
gcc exited with status 1

When I use the code above in a "normal" program it works fine. Could
someone tell me what I´m doing wrong?

Well, endl; is std::endl; but your'e not showiing code using either, making
me think you're not shwoing the entire code? I dont' se a main function so
it's not complete. Try giving us a complete program that produces the
error. You say you expect an .exe to be produced, so need a main().
 
S

Stefan Wagenbrenner

Jim said:
Well, endl; is std::endl; but your'e not showiing code using either, making
me think you're not shwoing the entire code?

The rest of the code was produced by Dev Cpp, so I omitted it. The code
posted by me was the only code which I wrote.

I dont' se a main function so
it's not complete. Try giving us a complete program that produces the
error. You say you expect an .exe to be produced, so need a main().

I don`t want to produce a .exe, producing a .exe which uses the function
in a main() does not cause an error.


Stefan Wagenbrenner
 
I

Ian Collins

Good morning,

I'm trying to write a dll using Dev Cpp 4. I'm able to compile the
following code, but the linker throws an error and no dll is produced:
You'll probably have more luck on a windows group, this a tool rather
than a language problem.
 
N

Nemanja Trifunovic

#include <stdio.h>
#include <windows.h>
#include <vector>

// ... more code ...

vector<char> charSubstring (char *str, int start, int ende)
{

Are you missing a

using namespace std;

statement?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top