473,750 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error when linking a Fortran library to c++ code in VC8

I get the following error when i try to link a fortran library to a c++ code
in .NET 2005.

LINK : fatal error LNK1104: cannot open file 'libc.lib'

the code was working fine when built using .NET2003.
also, when I do not try to link the fortran library (just to see if that was
the cause), it builds the exe without any problems.

i don't even know how to begin addressing this problem...any help would be
appreciated.

thanks,
Julian.
Mar 15 '06 #1
10 2690
"Julian" <ju****@nospamt amu.edu> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I get the following error when i try to link a fortran library to a c++
code in .NET 2005.

LINK : fatal error LNK1104: cannot open file 'libc.lib'

the code was working fine when built using .NET2003.
also, when I do not try to link the fortran library (just to see if that
was the cause), it builds the exe without any problems.

i don't even know how to begin addressing this problem...any help would be
appreciated.


The singly threaded library you mention has been removed from VS2005. See
here:

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

It should be a simple matter of switching to a multithreaded library to get
your project to build. This box does not have 2005 installed, but if you
have trouble finding the setting in the project's properties dialog, post
again and I'll reply with instructions later on the off chance no one else
sets you straight first.

Regards,
Will
Mar 15 '06 #2

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:ef******** ******@TK2MSFTN GP09.phx.gbl...

The singly threaded library you mention has been removed from VS2005. See
here:

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

It should be a simple matter of switching to a multithreaded library to
get your project to build. This box does not have 2005 installed, but if
you have trouble finding the setting in the project's properties dialog,
post again and I'll reply with instructions later on the off chance no one
else sets you straight first.

Regards,
Will


thanks for the reply.
I see that when I upgraded my c++ project from 2003 to 2005, it
automatically made it multi-threaded.
but it is the FORTRAN library that is single-threaded. so, I guess I need to
rebuild the FORTRAN library with the multi-thread option? in this particular
case, that is possible since I have the source code to the library. but what
if I was using a third-party library to which I didn't have the source?
would I be stuck then ?
also, in order to compile the FORTRAN library and get it running with my vc8
code, do I have to use the latest multi-threaded CRTs? or will any version
do (this is for rebuilding the FORTRAN library alone)?

Julian.
Mar 15 '06 #3
"Julian" <ju****@nospamt amu.edu> wrote in message
news:OO******** *****@TK2MSFTNG P14.phx.gbl...
thanks for the reply.
You are welcome.
I see that when I upgraded my c++ project from 2003 to 2005, it
automatically made it multi-threaded.
OK.
but it is the FORTRAN library that is single-threaded. so, I guess I need
to rebuild the FORTRAN library with the multi-thread option?
First the disclaimer: the last time I did any Fortran development on a
regular basis I was sitting at an IBM 029 keypunch nachine. I suspect that
things have changed a lot since the dark ages. :-)

That said, I don't think that you should have to rebuild your Fortran
library though I may be wrong.
but what if I was using a third-party library to which I didn't have the
source? would I be stuck then ?
The problem of mismatched libraries usually occurs when you try to pass
references to objects created in a component built with one library to a
component built in another. Passing, for example, C file handles or pointers
to blocks allocated with malloc() or the new operator, may bite you,
depending on how the callee uses them.

I doubt that either the C or C++ runtime is similar enough to that of
Fortran to allow this kind of problematic sharing. Of course, I could be
wrong.

Rather, I think that by using the multi-threaded runtime you will make your
application safe for multi-threading. With the single thread I expect that
you have, that should be a nit.
also, in order to compile the FORTRAN library and get it running with my
vc8 code, do I have to use the latest multi-threaded CRTs? or will any
version do (this is for rebuilding the FORTRAN library alone)?


As I said, I have to duck the Fortran questions because of my lack of
experience with it. Whose compiler are you using? And what does your library
do? If you post again, someone with Fortran knowledge may pop in. If no one
does, you might post again in

microsoft.publi c.vc.language

which I think sees a bit more traffic than this group.

Regards,
Will
Mar 15 '06 #4

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:ey******** ******@TK2MSFTN GP12.phx.gbl...
"Julian" <ju****@nospamt amu.edu> wrote in message
news:OO******** *****@TK2MSFTNG P14.phx.gbl...
thanks for the reply.


You are welcome.
I see that when I upgraded my c++ project from 2003 to 2005, it
automatically made it multi-threaded.


OK.
but it is the FORTRAN library that is single-threaded. so, I guess I need
to rebuild the FORTRAN library with the multi-thread option?


First the disclaimer: the last time I did any Fortran development on a
regular basis I was sitting at an IBM 029 keypunch nachine. I suspect that
things have changed a lot since the dark ages. :-)

That said, I don't think that you should have to rebuild your Fortran
library though I may be wrong.
but what if I was using a third-party library to which I didn't have the
source? would I be stuck then ?


The problem of mismatched libraries usually occurs when you try to pass
references to objects created in a component built with one library to a
component built in another. Passing, for example, C file handles or
pointers to blocks allocated with malloc() or the new operator, may bite
you, depending on how the callee uses them.

I doubt that either the C or C++ runtime is similar enough to that of
Fortran to allow this kind of problematic sharing. Of course, I could be
wrong.

Rather, I think that by using the multi-threaded runtime you will make
your application safe for multi-threading. With the single thread I expect
that you have, that should be a nit.
also, in order to compile the FORTRAN library and get it running with my
vc8 code, do I have to use the latest multi-threaded CRTs? or will any
version do (this is for rebuilding the FORTRAN library alone)?


As I said, I have to duck the Fortran questions because of my lack of
experience with it. Whose compiler are you using? And what does your
library do? If you post again, someone with Fortran knowledge may pop in.
If no one does, you might post again in

microsoft.publi c.vc.language

which I think sees a bit more traffic than this group.

Regards,
Will

actually, I went ahead and rebuilt the fortran library using the
multi-threaded option (using Digital Visual Fortran). and it worked ! VC8
linked the files this time with no errors !

thanks for the reply !
Mar 16 '06 #5
"Julian" <ju****@nospamt amu.edu> wrote in message
news:ug******** ******@TK2MSFTN GP14.phx.gbl...
actually, I went ahead and rebuilt the fortran library using the
multi-threaded option (using Digital Visual Fortran). and it worked ! VC8
linked the files this time with no errors !


Great!

Another option that probably would have worked would have been to add
/nodefaultlib:li bc.lib to your linker options. If you have another fotran
library that you can't rebuild, that might be an option for you.

-cd
Mar 16 '06 #6
> Great!

Another option that probably would have worked would have been to add
/nodefaultlib:li bc.lib to your linker options. If you have another fotran
library that you can't rebuild, that might be an option for you.

-cd

what actually happens when you do that ?
does that mean that it will force the fortran library to be a multi-threaded
library?

also, while i didn't get any errors, i did get this warning:
LINK : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other
libs; use /NODEFAULTLIB:li brary

can you explain that to me? what exactly is the conflict? and will that
cause problems for me later on?
I used "multithrea ded-debug" for the c++ program. and "multi-threaded" in
the debug configuration as the 'active configuration' for the fortran
library.

thanks,
Julian.
Mar 16 '06 #7
Julian wrote:
Great!

Another option that probably would have worked would have been to add
/nodefaultlib:li bc.lib to your linker options. If you have another
fotran library that you can't rebuild, that might be an option for
you. -cd

what actually happens when you do that ?
does that mean that it will force the fortran library to be a
multi-threaded library?

also, while i didn't get any errors, i did get this warning:
LINK : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of
other libs; use /NODEFAULTLIB:li brary

can you explain that to me? what exactly is the conflict? and will
that cause problems for me later on?
I used "multithrea ded-debug" for the c++ program. and
"multi-threaded" in the debug configuration as the 'active
configuration' for the fortran library.


Object files, regardless of the compiler they're created with, can contain
default library requests. These tell the linker to include a particular
library in the link even if it's not mentioned specifically in the linker
input settings.

The /nodefaultlib option tells the linker to ignore default library requests
for the named library. If symbols from that library are indeed needed,
either the library will have to be supplied explicitly in the linker input
settings or some other library will have to supply those symbols for the
link to complete without an error.

Now, here's the key - the different versions of the runtime library - libc,
libcmt, msvcrt and the debug versions of each of those all export the same
symbols, with a very few differences. For example, only the multi-threaded
libraries contain a definition for _beginthread().

Now, if your code is single threaded (which apparently it is, since you were
using the single-threaded libraries with VC6), then it's perfectly safe to
link that code against the multi-threaded runtime library. The fact that
you're linking a multi-threaded RTL doesn't make your code multi-threaded.
It simply means that you're linking with a version of the library that's
safe for use by multiple threads - it's also safe for use by a single
thread.

So, when you re-built your fortran code for multi-threaded, the compiler
emitted a default library record requesting libcmt.lib - the static
multi-threaded runtime library. Your program was actually linked against
msvcrt.lib - the import library for the DLL runtime library. As discussed
above, these libraries actually define all of the same symbols. The linker
is just warning you that the default library that was specified for your
fortran module duplicates symbols that are already in the link and suggests
that you use /nodefaultlib to suppress that default library request.

In your case, there's no harm in adding /nodefaultlib:li bcmt.lib to your
linker settings to quite the warning. If you'd rather not have a dependency
on msvcr80.dll, you can change your project settings to "Multi-threaded"
instead of the default "Multi-threaded DLL" so that your program is linked
against libcmt.lib instead of msvcrt.lib.

HTH

-cd
Mar 16 '06 #8

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:uA******** ******@TK2MSFTN GP11.phx.gbl...

Object files, regardless of the compiler they're created with, can contain
default library requests. These tell the linker to include a particular
library in the link even if it's not mentioned specifically in the linker
input settings.

The /nodefaultlib option tells the linker to ignore default library
requests for the named library. If symbols from that library are indeed
needed, either the library will have to be supplied explicitly in the
linker input settings or some other library will have to supply those
symbols for the link to complete without an error.

Now, here's the key - the different versions of the runtime library -
libc, libcmt, msvcrt and the debug versions of each of those all export
the same symbols, with a very few differences. For example, only the
multi-threaded libraries contain a definition for _beginthread().

Now, if your code is single threaded (which apparently it is, since you
were using the single-threaded libraries with VC6), then it's perfectly
safe to link that code against the multi-threaded runtime library. The
fact that you're linking a multi-threaded RTL doesn't make your code
multi-threaded. It simply means that you're linking with a version of the
library that's safe for use by multiple threads - it's also safe for use
by a single thread.

So, when you re-built your fortran code for multi-threaded, the compiler
emitted a default library record requesting libcmt.lib - the static
multi-threaded runtime library. Your program was actually linked against
msvcrt.lib - the import library for the DLL runtime library. As discussed
above, these libraries actually define all of the same symbols. The
linker is just warning you that the default library that was specified for
your fortran module duplicates symbols that are already in the link and
suggests that you use /nodefaultlib to suppress that default library
request.

In your case, there's no harm in adding /nodefaultlib:li bcmt.lib to your
linker settings to quite the warning. If you'd rather not have a
dependency on msvcr80.dll, you can change your project settings to
"Multi-threaded" instead of the default "Multi-threaded DLL" so that your
program is linked against libcmt.lib instead of msvcrt.lib.

HTH

-cd

thanks a lot for taking the time to explain all that. it did help a lot...
but i also have some questions:
how could you tell that my program was linked against msvcrt.lib? actually,
the project settings say "Multi-threaded Debug" and not "Multi-threaded
Debug DLL". this is in Property Pages -> C/C++ -> Code Generation -> Runtime
Library

is there some other place where i need to make this setting?
Mar 16 '06 #9

"Julian" <ju****@nospamt amu.edu> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:uA******** ******@TK2MSFTN GP11.phx.gbl...

Object files, regardless of the compiler they're created with, can
contain default library requests. These tell the linker to include a
particular library in the link even if it's not mentioned specifically in
the linker input settings.

The /nodefaultlib option tells the linker to ignore default library
requests for the named library. If symbols from that library are indeed
needed, either the library will have to be supplied explicitly in the
linker input settings or some other library will have to supply those
symbols for the link to complete without an error.

Now, here's the key - the different versions of the runtime library -
libc, libcmt, msvcrt and the debug versions of each of those all export
the same symbols, with a very few differences. For example, only the
multi-threaded libraries contain a definition for _beginthread().

Now, if your code is single threaded (which apparently it is, since you
were using the single-threaded libraries with VC6), then it's perfectly
safe to link that code against the multi-threaded runtime library. The
fact that you're linking a multi-threaded RTL doesn't make your code
multi-threaded. It simply means that you're linking with a version of the
library that's safe for use by multiple threads - it's also safe for use
by a single thread.

So, when you re-built your fortran code for multi-threaded, the compiler
emitted a default library record requesting libcmt.lib - the static
multi-threaded runtime library. Your program was actually linked against
msvcrt.lib - the import library for the DLL runtime library. As
discussed above, these libraries actually define all of the same symbols.
The linker is just warning you that the default library that was
specified for your fortran module duplicates symbols that are already in
the link and suggests that you use /nodefaultlib to suppress that default
library request.

In your case, there's no harm in adding /nodefaultlib:li bcmt.lib to your
linker settings to quite the warning. If you'd rather not have a
dependency on msvcr80.dll, you can change your project settings to
"Multi-threaded" instead of the default "Multi-threaded DLL" so that your
program is linked against libcmt.lib instead of msvcrt.lib.

HTH

-cd

thanks a lot for taking the time to explain all that. it did help a lot...
but i also have some questions:
how could you tell that my program was linked against msvcrt.lib?
actually, the project settings say "Multi-threaded Debug" and not
"Multi-threaded Debug DLL". this is in Property Pages -> C/C++ -> Code
Generation -> Runtime Library

is there some other place where i need to make this setting?


Process of elimination. Since I already knew that you'd changed from using
libc, the only other library that would conflict with libcmt is msvcrt.
Unless you're mixing debug and non-debug builds anyway!

If the fortran module is using libcmt and you're linking it with a debug
build, that'd produce the linker warning since your program would be using
libcmtd. You can tell which default library(ies) are specified in an .OBJ
file by using DUMPBIN /DIRECTIVES {your file here}. Dumpbin is in your
Visual Studio tools directory and should be on the PATH if you use the
command-prompt shortcut that was installed with Visual Studio.

-cd
Mar 17 '06 #10

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

Similar topics

1
4331
by: mccoyn | last post by:
I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors: LINK : error LNK2020: unresolved token (0600000E) PatInfo::.ctor LINK : error LNK2020: unresolved token (0600000F) PatInfo::Finalize LINK : fatal error LNK1120: 2 unresolved externals I've striped everything out of this library except for the single class which has an empty constructor...
2
1699
by: sunil | last post by:
Hi, We have lot of c and fortran archive libraries that have complex dependencies. We have different server tasks that use some of these libraries. We have developed a tool inhouse that links server tasks by continuously iterating until it figures out the correct library order. Recently we introduced some C++ legacy libraries. I am completely new to C++ linking. Is there some tutorial that can explain the nuances of C++ linking? We do...
13
2538
by: NM | last post by:
Sometimes ago I was having a problem in linking between C++ and Fortran program. That was solved (using input from this newsgroup) using the Fortran keyword "sequence" with the derived types (to assume contiguous space). Now I am having problem again. In order to show the problem I have created small program and this time there is no data straucture being passed between C++ and Fortran. Here is how the program looks like
7
6553
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems 1. Using the New Project wizard, generate a Visual C++ .NET Class Library project (call it "Doomed") and a VC++...
2
5331
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on python-list@python.org . - Josiah
2
1980
by: stevenruiz | last post by:
Hi Everyone, The Strings.h has the function Get_Line which is defined and the error is shown below: Strings.h: void get_line( istream & );
3
5698
by: Alexander Eisenhuth | last post by:
Hello, Ctrl+C is not passed to the interpreter (i guess it) while I'm executing a script. Instead i get: forrtl: error (200): program aborting due to control-C event If I start python in interactive mode Ctrl+C is passed: bash-3.2$ python Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win
9
3697
by: a-lbi | last post by:
I use gcc compiler (version 2.8.1). During linking I get the following error message: Undefined first referenced symbol in file log10l /opt/gcc_4.1.2/solaris10/lib/ libgfortran.a(write.o) strtof /opt/gcc_4.1.2/solaris10/lib/ libgfortran.a(read.o) strtold /opt/gcc_4.1.2/solaris10/lib/
7
1857
by: bajichuan | last post by:
Hello! I have the world's strangest linking error, and I'm hoping that someone can help me sort it out. I recently installed and compiled a library called LinBox without a problem. I have an object-oriented software application, and I want it to call the library. When I add the following 3 lines (copied directly from the library tutorial), #include <linbox/field/modular.h> using namespace LinBox; typedef Modular<shortField;
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9338
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.