|
Project's Property Pages dialog box -> Linker->Input. Add msvcrt.lib to the Additional Dependencies.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
thanks man, i've done that but i am stil getting errors when linking, just two though...
Linking...
libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
libcpmtd.lib(_tolower.obj) : error LNK2001: unresolved external symbol __malloc_dbg
libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
C:\Documents and Settings\Major Pigeon\My Documents\Visual Studio Projects\fooManaged\Debug\fooManaged.dll : fatal error LNK1120: 2 unresolved externals
|
|
|
|
|
Ok so I've got my C++/CLI solution, which now includes some old native C files (not C++ files). I don't want these C files to be compiled to managed; I just want to be able to call them from my managed ref classes in my C++/CLI solution. How can I do that? The compiler complains it won't compile .c files with the /clr syntax.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lent Revisited
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Judah Himango wrote: The compiler complains it won't compile .c files with the /clr syntax.
Yeah, one of "advances" that came with VS2005.
Anyway, try to simply rename the c files to cpp and compile. You may get some compiler errors, but they should not be hard to fix.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Nemanja Trifunovic wrote: Anyway, try to simply rename the c files to cpp and compile. You may get some compiler errors, but they should not be hard to fix.
Or put the C files into a native DLL and export the required functions out of it.
Regards,
Nish
|
|
|
|
|
Nishant Sivakumar wrote: Or put the C files into a native DLL and export the required functions out of it.
Out of curiosity - would it work with a static lib rather than a dll? I am too lazy to try
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Nemanja Trifunovic wrote: Out of curiosity - would it work with a static lib rather than a dll? I am too lazy to try
I haven't tried a static lib myself either, but I do remember a few people complaining how that's caused problems for them.
Regards,
Nish
|
|
|
|
|
I'm not a C++ guy by trade, so maybe this is a stupid question, but how do I export the native functions out of it so that my C++/CLI dll can see those functions?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lent Revisited
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
|
|
Yeah I tried that, several hundred compiler errors. Even if I did get it to compile, wouldn't that be compiled to managed code? I don't need this particular piece of code in managed land...
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lent Revisited
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I've got a C++/CLI library I'm using to wrap some native C methods in order to call them easily from another .NET language.
This is probably an easy question, but how can I convert a .NET string (System::String) to a LPCSTR? I'm new the the CLI extensions for C++, and google doesn't give me anything other than the old MSDN article which refers to solutions using the old MC++ syntax.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lent Revisited
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Judah Himango wrote: I've got a C++/CLI library I'm using to wrap some native C methods in order to call them easily from another .NET language.
This is probably an easy question, but how can I convert a .NET string (System::String) to a LPCSTR? I'm new the the CLI extensions for C++, and google doesn't give me anything other than the old MSDN article which refers to solutions using the old MC++ syntax.
Hello Judah,
See http://www.codeproject.com/managedcpp/StringConvertor.asp[^]
If you don't want to use the class, look at the source code to see how it's done.
Regards,
Nish
|
|
|
|
|
|
Hi..I need a sample code or a dll that detect if any hardware connected to parallel port and usb.
karanba
|
|
|
|
|
One solution to serial port communication is CreateFile() if you are running on Win32 console.
Kuphryn
|
|
|
|
|
I need to know how I can read the content of a pdf document using c++.
Allang Garder
|
|
|
|
|
Allang Garder wrote: using c++.
do you know this is the Managed C++ forum (for .NET framework so) ?
|
|
|
|
|
How would you do it in cli? I would
be interested.
|
|
|
|
|
hi, i am having some trouble with this basic example code, i can't figure out why i am getting an error, null reference!
please help
thanks
#include "stdafx.h"<br />
<br />
#using mscorlib.dll<br />
using namespace std; <br />
<br />
<br />
class Foo<br />
{<br />
public:<br />
Foo();<br />
~Foo();<br />
void DoSomeFoo();<br />
};<br />
<br />
Foo::Foo() <br />
{<br />
cout<<"Constructor called!"<<endl;<br />
}<br />
Foo::~Foo() <br />
{<br />
cout<<"Destructor called"<<endl;<br />
}<br />
<br />
void Foo::DoSomeFoo()<br />
<br />
{<br />
cout<<"Do something funny!"<<endl;<br />
cout<<"Burrrp!"<<endl;<br />
}<br />
<br />
__gc class MFoo<br />
{ <br />
private:<br />
Foo * _foo;<br />
public:<br />
MFoo();<br />
~MFoo();<br />
void ManagedDoSomeFoo();<br />
};<br />
<br />
MFoo::MFoo() <br />
{<br />
_foo = new Foo();<br />
}<br />
MFoo::~MFoo()<br />
{<br />
delete _foo;<br />
}<br />
<br />
void MFoo::ManagedDoSomeFoo() <br />
{<br />
_foo->DoSomeFoo();<br />
}<br />
<br />
<br />
int _tmain() <br />
{ <br />
<br />
<br />
MFoo*myfoo;<br />
myfoo->ManagedDoSomeFoo();<br />
<br />
return 0; <br />
}
|
|
|
|
|
where in the code are you getting this error, and what does the error message say ?
does it happen at runtime or before ?
|
|
|
|
|
Your never actually creating an instance of myfoo , try changing your _tmain to:
int _tmain()
{
MFoo*myfoo = new MFoo( );
myfoo->ManagedDoSomeFoo();
return 0;
}
Gavin Taylor
w: http://www.gavspace.com
-- modified at 5:39 Wednesday 8th March, 2006
|
|
|
|
|
thanks guys, i thought it was something like that,but i mainly use vb.net so i get a little stuck with c++.
i have been trying to wrap this example, so i can practice for a much bigger program.
i have never done this before and the help on the net is a little vague, i need a very very basic walkthrough, because the ones i have found won't compile, and its hard enough trying to debug code that you dont really understand.
i know this much....
i have a class library(.net) called fooManaged and its automatical created fooManaged.h. and i created UnManaged.h
in the UnManaged.h file i have this code.....
#include iostream <br />
#include vcclr.h<br />
using namespace std;<br />
<br />
class Foo<br />
{<br />
public:<br />
Foo();<br />
~Foo();<br />
void DoSomeFoo();<br />
};<br />
<br />
Foo::Foo() <br />
{<br />
cout<<"Constructor called!"<<endl;<br />
}<br />
Foo::~Foo() <br />
{<br />
cout<<"Destructor called"<<endl;<br />
}<br />
<br />
void Foo::DoSomeFoo(void)<br />
<br />
{<br />
cout<<"Do something funny!"<<endl;<br />
cout<<"Burrrp!"<<endl;<br />
}
in fooManaged.h i have this code....
<br />
#pragma once<br />
using namespace System;<br />
<br />
namespace fooManaged<br />
{<br />
public __gc class MFoo<br />
{ <br />
private:<br />
Foo * _foo;<br />
public:<br />
MFoo();<br />
~MFoo();<br />
void ManagedDoSomeFoo();<br />
};<br />
MFoo::MFoo() <br />
{<br />
_foo = new Foo();<br />
}<br />
MFoo::~MFoo()<br />
{<br />
delete _foo;<br />
}<br />
<br />
void MFoo::ManagedDoSomeFoo() <br />
{<br />
_foo->DoSomeFoo();<br />
}<br />
<br />
}
the fooManaged.cpp file just has...
#include "stdafx.h"
#include "Unmanagedfoo.h"
#include "fooManaged.h"
#using mscorlib.dll
it all compiles...but there is a big linking error!!
Compiling...
fooManaged.cpp
Linking...
LINK : error LNK2020: unresolved token (0A000005) _CxxThrowException
LINK : error LNK2020: unresolved token (0A000019) free
LINK : error LNK2020: unresolved token (0A00001A) strlen
LINK : error LNK2020: unresolved token (0A00001B) memmove
LINK : error LNK2020: unresolved token (0A00001C) memcpy
LINK : error LNK2020: unresolved token (0A00001D) delete
LINK : fatal error LNK1120: 6 unresolved externals
i must be doing something wrong, some help with this will be very wecome
thanks
|
|
|
|
|
hi every1
will u plz help me on this ...
im creating a generic container class and im implemeting it using the (void*) pointer technique
but to add a search feature, the search function should compare two (void*) variables, i dont know how to do that!
i think memcmp could be used somehow but the problem that it needs a length parameter which is now available!!
thanks already
|
|
|
|
|
you are on the C++/CLI forum[^], while you question is for the Visual C++ forum[^]
next time, be careful...
and for you problem, do you code in C or C++ ?
because C++ provides templates, that may certainly interrest you...
|
|
|
|