www.digitalmars.com         C & C++   DMDScript  

c++ - writing c code in a c++ app

reply david <david_member pathlink.com> writes:
Hello,

I am having difficulties in writing a c++ prog that uses C code to send an icmp
packet (icmpapi.h, ipexport.h (used by icmpapi.h)).  This is what my code looks
like so far:



-------------------------------------
#include <iostream>
#include <windows.h>

extern "C" {
#include <icmpapi.h>
}

int main(){
using namespace std;
HANDLE icmp;
icmp = IcmpCreateFile();

cout << "hello";
return 0;
}
________________________________________________


It compiles but then i get an error that says:

_______________________________________________
hello.obj(hello)
Error 42: Symbol Undefined _IcmpCreateFile 0

--- errorlevel 1
_______________________________________________




Before i added the:
extern "C" 

I would get the error:

_____________________________________________________________________
hello.obj(hello)
Error 42: Symbol Undefined ?IcmpCreateFile  YGPAXXZ (void *stdcall
IcmpCreateFile (void ))

--- errorlevel 1
_____________________________________________________________________


Any insight would be greatly appreciated.  Is there a way to send a custom icmp
packet using C++ libraries?  This might help some.  The code for sending the
exact packet I need to send is already written in C for me, so ideally I would
like to write a C++ prog that does some extra work but also sends the icmp
packet (exactly as written in the already existing C code that I have).


Thank you,

David S
Feb 10 2005
parent reply Jack <Jack_member pathlink.com> writes:
You have to link it together with the import library of icmp.dll. You can make
the import library yourself.
Start command prompt and type this:
implib c:\apps\dm\lib\icmp.lib C:\WINNT\system32\icmp.dll (or
C:\WINDOWS\system32\icmp.dll for winxp)

Just link it together when you compile your source:
dmc hello.cpp icmp.lib

or if you just compile the source only (with the -c option) and you would like
to link it yourself:
link hello.obj icmp.lib

In article <cugbdi$2ohp$1 digitaldaemon.com>, david says...
Hello,

I am having difficulties in writing a c++ prog that uses C code to send an icmp
packet (icmpapi.h, ipexport.h (used by icmpapi.h)).  This is what my code looks
like so far:



-------------------------------------
#include <iostream>
#include <windows.h>

extern "C" {
#include <icmpapi.h>
}

int main(){
using namespace std;
HANDLE icmp;
icmp = IcmpCreateFile();

cout << "hello";
return 0;
}
________________________________________________


It compiles but then i get an error that says:

_______________________________________________
hello.obj(hello)
Error 42: Symbol Undefined _IcmpCreateFile 0

--- errorlevel 1
_______________________________________________




Before i added the:
extern "C" 

I would get the error:

_____________________________________________________________________
hello.obj(hello)
Error 42: Symbol Undefined ?IcmpCreateFile  YGPAXXZ (void *stdcall
IcmpCreateFile (void ))

--- errorlevel 1
_____________________________________________________________________


Any insight would be greatly appreciated.  Is there a way to send a custom icmp
packet using C++ libraries?  This might help some.  The code for sending the
exact packet I need to send is already written in C for me, so ideally I would
like to write a C++ prog that does some extra work but also sends the icmp
packet (exactly as written in the already existing C code that I have).


Thank you,

David S
Feb 11 2005
parent reply david <david_member pathlink.com> writes:
When i attempt:
dmc hello.cpp icmp.lib
it says:
Error 43:  Not a Valid Library File

The file is in the 'lib' directory and it does indicate that its attempting to
link the .lib file.  Do I just have a bad .lib file?  What about the icmp.dll
file?  Does the .lib file use the .dll file in the system32 folder?  I have one
in my system32 right now, so I am assuming I am ok there.

Thank you,

David

In article <cuif84$235e$1 digitaldaemon.com>, Jack says...
You have to link it together with the import library of icmp.dll. You can make
the import library yourself.
Start command prompt and type this:
implib c:\apps\dm\lib\icmp.lib C:\WINNT\system32\icmp.dll (or
C:\WINDOWS\system32\icmp.dll for winxp)

Just link it together when you compile your source:
dmc hello.cpp icmp.lib

or if you just compile the source only (with the -c option) and you would like
to link it yourself:
link hello.obj icmp.lib

In article <cugbdi$2ohp$1 digitaldaemon.com>, david says...
Hello,

I am having difficulties in writing a c++ prog that uses C code to send an icmp
packet (icmpapi.h, ipexport.h (used by icmpapi.h)).  This is what my code looks
like so far:



-------------------------------------
#include <iostream>
#include <windows.h>

extern "C" {
#include <icmpapi.h>
}

int main(){
using namespace std;
HANDLE icmp;
icmp = IcmpCreateFile();

cout << "hello";
return 0;
}
________________________________________________


It compiles but then i get an error that says:

_______________________________________________
hello.obj(hello)
Error 42: Symbol Undefined _IcmpCreateFile 0

--- errorlevel 1
_______________________________________________




Before i added the:
extern "C" 

I would get the error:

_____________________________________________________________________
hello.obj(hello)
Error 42: Symbol Undefined ?IcmpCreateFile  YGPAXXZ (void *stdcall
IcmpCreateFile (void ))

--- errorlevel 1
_____________________________________________________________________


Any insight would be greatly appreciated.  Is there a way to send a custom icmp
packet using C++ libraries?  This might help some.  The code for sending the
exact packet I need to send is already written in C for me, so ideally I would
like to write a C++ prog that does some extra work but also sends the icmp
packet (exactly as written in the already existing C code that I have).


Thank you,

David S
Feb 16 2005
parent reply Jack <Jack_member pathlink.com> writes:
use the one I attached on this message (icmp.zip)

In article <cv1fro$2aht$1 digitaldaemon.com>, david says...
When i attempt:
dmc hello.cpp icmp.lib
it says:
Error 43:  Not a Valid Library File

The file is in the 'lib' directory and it does indicate that its attempting to
link the .lib file.  Do I just have a bad .lib file?  What about the icmp.dll
file?  Does the .lib file use the .dll file in the system32 folder?  I have one
in my system32 right now, so I am assuming I am ok there.

Thank you,

David

In article <cuif84$235e$1 digitaldaemon.com>, Jack says...
You have to link it together with the import library of icmp.dll. You can make
the import library yourself.
Start command prompt and type this:
implib c:\apps\dm\lib\icmp.lib C:\WINNT\system32\icmp.dll (or
C:\WINDOWS\system32\icmp.dll for winxp)

Just link it together when you compile your source:
dmc hello.cpp icmp.lib

or if you just compile the source only (with the -c option) and you would like
to link it yourself:
link hello.obj icmp.lib

In article <cugbdi$2ohp$1 digitaldaemon.com>, david says...
Hello,

I am having difficulties in writing a c++ prog that uses C code to send an icmp
packet (icmpapi.h, ipexport.h (used by icmpapi.h)).  This is what my code looks
like so far:



-------------------------------------
#include <iostream>
#include <windows.h>

extern "C" {
#include <icmpapi.h>
}

int main(){
using namespace std;
HANDLE icmp;
icmp = IcmpCreateFile();

cout << "hello";
return 0;
}
________________________________________________


It compiles but then i get an error that says:

_______________________________________________
hello.obj(hello)
Error 42: Symbol Undefined _IcmpCreateFile 0

--- errorlevel 1
_______________________________________________




Before i added the:
extern "C" 

I would get the error:

_____________________________________________________________________
hello.obj(hello)
Error 42: Symbol Undefined ?IcmpCreateFile  YGPAXXZ (void *stdcall
IcmpCreateFile (void ))

--- errorlevel 1
_____________________________________________________________________


Any insight would be greatly appreciated.  Is there a way to send a custom icmp
packet using C++ libraries?  This might help some.  The code for sending the
exact packet I need to send is already written in C for me, so ideally I would
like to write a C++ prog that does some extra work but also sends the icmp
packet (exactly as written in the already existing C code that I have).


Thank you,

David S
begin 0644 icmp.zip MTE3O/<FW 2AGT 5:HK)('VU9)V0 :[<'68NL$G4MU-6[:*"LP,%VE+^U6?XP MS`61V06F?8R?.LI$2!W9_,7%2AHH+3DV*6)(F A(K^H_HJ%B?3<J5F9W.ZX_ MM&]02P$"%``4``(`"``%B%$R0+VJO'$!````"```"````````````"`````` A````:6-M<"YL:6)02P4&``````$``0`V````EP$````` ` end
Feb 17 2005
parent reply david <david_member pathlink.com> writes:
Jack,
When I click on the link, the browser just hangs.  Could you please send the
file to david.b.salgado gmail.com.

Thank you,
David

In article <cv1mts$2ir0$1 digitaldaemon.com>, Jack says...
use the one I attached on this message (icmp.zip)

In article <cv1fro$2aht$1 digitaldaemon.com>, david says...
When i attempt:
dmc hello.cpp icmp.lib
it says:
Error 43:  Not a Valid Library File

The file is in the 'lib' directory and it does indicate that its attempting to
link the .lib file.  Do I just have a bad .lib file?  What about the icmp.dll
file?  Does the .lib file use the .dll file in the system32 folder?  I have one
in my system32 right now, so I am assuming I am ok there.

Thank you,

David

In article <cuif84$235e$1 digitaldaemon.com>, Jack says...
You have to link it together with the import library of icmp.dll. You can make
the import library yourself.
Start command prompt and type this:
implib c:\apps\dm\lib\icmp.lib C:\WINNT\system32\icmp.dll (or
C:\WINDOWS\system32\icmp.dll for winxp)

Just link it together when you compile your source:
dmc hello.cpp icmp.lib

or if you just compile the source only (with the -c option) and you would like
to link it yourself:
link hello.obj icmp.lib

In article <cugbdi$2ohp$1 digitaldaemon.com>, david says...
Hello,

I am having difficulties in writing a c++ prog that uses C code to send an icmp
packet (icmpapi.h, ipexport.h (used by icmpapi.h)).  This is what my code looks
like so far:



-------------------------------------
#include <iostream>
#include <windows.h>

extern "C" {
#include <icmpapi.h>
}

int main(){
using namespace std;
HANDLE icmp;
icmp = IcmpCreateFile();

cout << "hello";
return 0;
}
________________________________________________


It compiles but then i get an error that says:

_______________________________________________
hello.obj(hello)
Error 42: Symbol Undefined _IcmpCreateFile 0

--- errorlevel 1
_______________________________________________




Before i added the:
extern "C" 

I would get the error:

_____________________________________________________________________
hello.obj(hello)
Error 42: Symbol Undefined ?IcmpCreateFile  YGPAXXZ (void *stdcall
IcmpCreateFile (void ))

--- errorlevel 1
_____________________________________________________________________


Any insight would be greatly appreciated.  Is there a way to send a custom icmp
packet using C++ libraries?  This might help some.  The code for sending the
exact packet I need to send is already written in C for me, so ideally I would
like to write a C++ prog that does some extra work but also sends the icmp
packet (exactly as written in the already existing C code that I have).


Thank you,

David S
begin 0644 icmp.zip MTE3O/<FW 2AGT 5:HK)('VU9)V0 :[<'68NL$G4MU-6[:*"LP,%VE+^U6?XP MS`61V06F?8R?.LI$2!W9_,7%2AHH+3DV*6)(F A(K^H_HJ%B?3<J5F9W.ZX_ MM&]02P$"%``4``(`"``%B%$R0+VJO'$!````"```"````````````"`````` A````:6-M<"YL:6)02P4&``````$``0`V````EP$````` ` end
Feb 18 2005
parent Jack <Jack_member pathlink.com> writes:
I keep receiving the message "delivery failure" while trying to send the file to
your email. So I just upload the file at here:
http://www.freewebs.com/jackliew/icmp.zip


In article <cv4bac$2981$1 digitaldaemon.com>, david says...
Jack,
When I click on the link, the browser just hangs.  Could you please send the
file to david.b.salgado gmail.com.

Thank you,
David

In article <cv1mts$2ir0$1 digitaldaemon.com>, Jack says...
use the one I attached on this message (icmp.zip)

In article <cv1fro$2aht$1 digitaldaemon.com>, david says...
When i attempt:
dmc hello.cpp icmp.lib
it says:
Error 43:  Not a Valid Library File

The file is in the 'lib' directory and it does indicate that its attempting to
link the .lib file.  Do I just have a bad .lib file?  What about the icmp.dll
file?  Does the .lib file use the .dll file in the system32 folder?  I have one
in my system32 right now, so I am assuming I am ok there.

Thank you,

David

In article <cuif84$235e$1 digitaldaemon.com>, Jack says...
You have to link it together with the import library of icmp.dll. You can make
the import library yourself.
Start command prompt and type this:
implib c:\apps\dm\lib\icmp.lib C:\WINNT\system32\icmp.dll (or
C:\WINDOWS\system32\icmp.dll for winxp)

Just link it together when you compile your source:
dmc hello.cpp icmp.lib

or if you just compile the source only (with the -c option) and you would like
to link it yourself:
link hello.obj icmp.lib

In article <cugbdi$2ohp$1 digitaldaemon.com>, david says...
Hello,

I am having difficulties in writing a c++ prog that uses C code to send an icmp
packet (icmpapi.h, ipexport.h (used by icmpapi.h)).  This is what my code looks
like so far:



-------------------------------------
#include <iostream>
#include <windows.h>

extern "C" {
#include <icmpapi.h>
}

int main(){
using namespace std;
HANDLE icmp;
icmp = IcmpCreateFile();

cout << "hello";
return 0;
}
________________________________________________


It compiles but then i get an error that says:

_______________________________________________
hello.obj(hello)
Error 42: Symbol Undefined _IcmpCreateFile 0

--- errorlevel 1
_______________________________________________




Before i added the:
extern "C" 

I would get the error:

_____________________________________________________________________
hello.obj(hello)
Error 42: Symbol Undefined ?IcmpCreateFile  YGPAXXZ (void *stdcall
IcmpCreateFile (void ))

--- errorlevel 1
_____________________________________________________________________


Any insight would be greatly appreciated.  Is there a way to send a custom icmp
packet using C++ libraries?  This might help some.  The code for sending the
exact packet I need to send is already written in C for me, so ideally I would
like to write a C++ prog that does some extra work but also sends the icmp
packet (exactly as written in the already existing C code that I have).


Thank you,

David S
Feb 19 2005