By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,935 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,935 IT Pros & Developers. It's quick & easy.

How to work with Header files(.h) and lib files in C

P: n/a
Hi!all. As part of the course project in the university, students
have been given task to develop a front-end for SMILE( an API written
in C++ for network modelling). Upon extracting the setup, it gives a
collection of " Header files and Lib files" written in c++.

Now, how do i add them in c# to use the existing api to create a
front-end. I do know that we can include the reference for any .dll
file and use it. But don't know how to use existing header files and
lib files in c#.

Can somebody guide me and help me on this issue, if somebody has
worked with C++ header files or done any sort of work on SMILE.

Would be really thankful personally, and it will be great help for
the students of this course project.

Sep 9 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
weird0,

See inline:

"weird0" <am********@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Hi!all. As part of the course project in the university, students
have been given task to develop a front-end for SMILE( an API written
in C++ for network modelling). Upon extracting the setup, it gives a
collection of " Header files and Lib files" written in c++.

Now, how do i add them in c# to use the existing api to create a
front-end. I do know that we can include the reference for any .dll
file and use it. But don't know how to use existing header files and
lib files in c#.
You can't create a reference to ANY .dll file and use it. The only way
you can add a reference to a .dll file is if it is a .NET assembly, or if it
is a COM assembly (in which case, you really reference the assembly
generated by TLBIMP, the COM wrapper generator).
Can somebody guide me and help me on this issue, if somebody has
worked with C++ header files or done any sort of work on SMILE.
What you need to do is declare the types and functions that you are
going to call. In general, you are using the P/Invoke layer. Here is a
reference to get your started:

http://msdn2.microsoft.com/en-us/library/fzhhdwae.aspx

Specifically, the section on consuming unmanaged DLL functions would be
helpful as well:

http://msdn2.microsoft.com/en-us/library/26thfadc.aspx
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Would be really thankful personally, and it will be great help for
the students of this course project.
Sep 9 '07 #2

P: n/a
Oh, and one other thing, if you have a .lib file, you are going to have
to create a DLL file which exposes the functions you want to call. You
can't access lib files directly from .NET.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:1F**********************************@microsof t.com...
weird0,

See inline:

"weird0" <am********@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
>Hi!all. As part of the course project in the university, students
have been given task to develop a front-end for SMILE( an API written
in C++ for network modelling). Upon extracting the setup, it gives a
collection of " Header files and Lib files" written in c++.

Now, how do i add them in c# to use the existing api to create a
front-end. I do know that we can include the reference for any .dll
file and use it. But don't know how to use existing header files and
lib files in c#.

You can't create a reference to ANY .dll file and use it. The only way
you can add a reference to a .dll file is if it is a .NET assembly, or if
it is a COM assembly (in which case, you really reference the assembly
generated by TLBIMP, the COM wrapper generator).
>Can somebody guide me and help me on this issue, if somebody has
worked with C++ header files or done any sort of work on SMILE.

What you need to do is declare the types and functions that you are
going to call. In general, you are using the P/Invoke layer. Here is a
reference to get your started:

http://msdn2.microsoft.com/en-us/library/fzhhdwae.aspx

Specifically, the section on consuming unmanaged DLL functions would be
helpful as well:

http://msdn2.microsoft.com/en-us/library/26thfadc.aspx
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

>Would be really thankful personally, and it will be great help for
the students of this course project.
Sep 9 '07 #3

P: n/a
You can write managed wrapper classes in a mixed assembly using C++/CLI.

--
Sheng Jiang
Microsoft MVP in VC++
"weird0" <am********@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Hi!all. As part of the course project in the university, students
have been given task to develop a front-end for SMILE( an API written
in C++ for network modelling). Upon extracting the setup, it gives a
collection of " Header files and Lib files" written in c++.

Now, how do i add them in c# to use the existing api to create a
front-end. I do know that we can include the reference for any .dll
file and use it. But don't know how to use existing header files and
lib files in c#.

Can somebody guide me and help me on this issue, if somebody has
worked with C++ header files or done any sort of work on SMILE.

Would be really thankful personally, and it will be great help for
the students of this course project.

Sep 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.