473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Linking external dlls

My apologies if this is a trivial problem. I have been trying to solve
this for a few days now and I just can't get it done. Here's what I have. I
have a C++ project in VisualStudio.NET whose code relies on external C code
(GNU Scientific Library). That external code I added using
Configuration Properties->Linker->Input->Additional Dependencies
There, I specified two .lib files and the code compiles just fine. However,
when it generates the output dll's (the project is supposed to produce a
dll that is being used elseplace) the external code's dll's aren't copied
over. So I tried to the external code's dll's using "References" but that
just won't work (don't know why - the error message is non-descriptive). So
here's the question: How do I link those external libraries so that when
some other code wants to use the dll the external libraries' dll's get
copied over properly?
Should I, instead of doing the linking the way I do it, invoke the
code using dllImport? The important thing here is that the code compiles
and runs just fine the way I do it - the only problem is that the
external dlls don't get deployed properly. That's particularly bad for
the case where I use the C code inside a .NET web application: The
code won't run unless I copy the dlls by hand (hardly a solution for
a web application).
- Joerg Colberg
as***@bruno.phyast.pitt.edu
Nov 17 '05 #1
5 1370
"Joerg M. Colberg" <co*****@bruno.phyast.pitt.edu> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
My apologies if this is a trivial problem.
:-) This is a low-flame group.
I have been trying to solve this for a few days
now and I just can't get it done. Here's what I have. I
have a C++ project in VisualStudio.NET whose code
relies on external C code (GNU Scientific Library). That
external code I added using Configuration
Properties->Linker->Input->Additional Dependencies
There, I specified two .lib files and the code compiles
just fine.
So far, so good.
However, when it generates the output dll's (the
project is supposed to produce a dll that is being used
elseplace) the external code's dll's aren't copied over.


Right. They won't be. At runtime Windows searches for DLLs in an order that
is described in the Remarks section on this page:

http://msdn.microsoft.com/library/de...oadlibrary.asp

If you want the DLLs to be implicitly loaded then you have to put the
dependent DLLs where the loader will look for them.

Regards,
Will
Nov 17 '05 #2
Hi Will,

Thanks for the answer! I have a follow-up:
However, when it generates the output dll's (the
project is supposed to produce a dll that is being used
elseplace) the external code's dll's aren't copied over.
Right. They won't be. At runtime Windows searches for DLLs in an order
that is described in the Remarks section on this page:

http://msdn.microsoft.com/library/de...oadlibrary.asp
If you want the DLLs to be implicitly loaded then you have to put the
dependent DLLs where the loader will look for them.


Where would that be? In particular, when I incorporate the
C code into a web application I need to make sure the dlls get
accessed. For example, if I put the dlls into a directory that's
in the PATH (or even into the system directory [I'm somewhat
reluctant to do that...]) would the web server look there?

Best,
Joerg
Nov 17 '05 #3
"Joerg M. Colberg" <co*****@bruno.phyast.pitt.edu> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Thanks for the answer! I have a follow-up:
You are welcome.

http://msdn.microsoft.com/library/de...oadlibrary.asp

If you want the DLLs to be implicitly loaded then you have to put the
dependent DLLs where the loader will look for them.

Where would that be?
The loader's search order is spelled out in the remarks section of the help
entry on the LoadLibrary() function above.
In particular, when I incorporate the
C code into a web application I need to make sure the dlls get
accessed. For example, if I put the dlls into a directory that's
in the PATH (or even into the system directory [I'm somewhat
reluctant to do that...]) would the web server look there?


If we are talking about implicit linking, as would be the case when your DLL
is linked against the third party's DLL, then at the time your DLL is loaded
Windows' loader will try to resolve the imported references in your DLL
using the search order above.

If your DLL is implicitly linked against the web server, then the loader
will search the directory containing the web server and the current
directory in force at the launch of the web server.

If your DLL is explicitly loaded then the current directory is the current
directory in force when the web server calls LoadLibrary() to load your DLL.

Your reluctance to pollute the Windows directory or Windows system directory
is a point of view appreciated by system administrators the world over.
There are those people who do that, though, because an application can
continue to work even if the user copies it manually to another directory as
the system directory doesn't move.

That approach devolves into something called "DLL hell" when the third party
DLL is a common one which is installed by two applications which use
different versions of it. That can and often does break something. :-)

So, these days, people tend not to worry about the waste in disk space but
tend to put the DLLs used by an application, even if shared, in one of the
application's directories.

Does the web server not spell out a "best practices" policy?

Regards,
Will
Nov 17 '05 #4
Hi Will,
Your reluctance to pollute the Windows directory or Windows system
directory is a point of view appreciated by system administrators the
world over. There are those people who do that, though, because an
application can continue to work even if the user copies it manually to
another directory as the system directory doesn't move.

That approach devolves into something called "DLL hell" when the third
party DLL is a common one which is installed by two applications which use
different versions of it. That can and often does break something. :-)

So, these days, people tend not to worry about the waste in disk space but
tend to put the DLLs used by an application, even if shared, in one of the
application's directories.


I'm in a bit of a dilemma here because I don't really know the webserver
to well, and all my efforts to put those dll's into places where I thought
the webserver would look didn't work. So I ended up putting the dll's into
the Windows system directory *boooo hisss*. Given the fact that I am also
the system admin I don't expect any trouble from that guy. ;-) But
seriously, I think putting the dll's there is... well... let's call it
OK: I will never ever change the dll's myself and I don't expect them to
change (it's a bunch of libraries used for all kinds of scientific
programming). On top of that, I need to focus on getting the application
running etc. so I can't afford to spend too much time on this. Hardly
ideal, but what can you do?
In any case, your comments helped me solve the problem. If I ever
manage to find out where else I can put the dll's I'll put them there
and clean up the system directory. But you know, it's a Windows system
and Windows isn't exactly know for pretty solutions. ;-)

Anyway, thanks a bunch for the help!

Best,
Joerg
Nov 17 '05 #5
"Joerg M. Colberg" <co*****@bruno.phyast.pitt.edu> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I'm in a bit of a dilemma here because I don't really know the webserver
to well, and all my efforts to put those dll's into places where I thought
the webserver would look didn't work. So I ended up putting the dll's into
the Windows system directory *boooo hisss*. ...
On top of that, I need to focus on getting the application
running etc. so I can't afford to spend too much time on this. Hardly
ideal, but what can you do?
That's the usual quandary.
But you know, it's a Windows system and
Windows isn't exactly know for pretty solutions. ;-)
Joerg, Joerg, Joerg. :-)

You know if you said you were using IIS and its ISAPI extensions I could
have pointed you to an ISAPI group where I'm sure you could get lots of
information on best practices for deployment. This is Windows, after all,
and there is more written and known about Windows than any antique operating
system whose name ends in X. <BSEG> There are even books that document the
undocumented.

And look at the loader's search algorithm. There are plenty of places to put
things besides the system directory. You can't blame Windows. It offers you
choices, some better than others. In the end, we are all responsible for our
choices.
Anyway, thanks a bunch for the help!


You are welcome.

Regards,
Will
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bobnotbob | last post by:
I have created an application and am trying to call functions from a previously existing dll. I can call some functions fine, but I get a link error an when I try to call any function that takes...
2
by: | last post by:
Help! I'm new to c++, and am breaking my teeth on MS Visual C++ (bundled within Visual Studio .NET 2003). Am trying to link simple c++ code to fortran dlls created in Compaq Visual Fortran (v6.1)....
1
by: Joannes Vermorel | last post by:
I am currently trying to port a small open source scientfic library written in C++ to .Net. The code (including the VS solution) could be found at http://www.vermorel.com/opensource/selfscaling.zip...
2
by: Joerg M. Colberg | last post by:
I have a VS.Net solution that contains various projects. Some of the projects contain programme blocks (legacy code) that are used by some of the other projects. One project contains some C code...
4
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the...
11
by: Sean M. DonCarlos | last post by:
I have an unmanaged Win32 app that looks up the name of a DLL (unknown at compile time) from an external location, loads it with LoadLibrary, and then uses GetProcAddress on three exported...
0
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when...
0
by: JohnIdol | last post by:
VC++6 to VC++2003 - linking troubles -------------------------------------------------------------------------------- Hi All, I successfully ported an application from VC++6 to VS2003. Solved...
1
by: Angela Yan | last post by:
Hi all, I have a dll compiled using DDK 3790.1218 WNet environment. Everything works fine until recently I need to link a Lib file that is complied using C++ in VS2005. After I add the Lib file...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.