/MD is a compiler option. Try it on your compile command line, rather than
your linker command line.
Thanks,
Kang Su Gatlin
Visual C++ Program Manager
File bugs in Visual Studio/.NET at:
http://msdn.microsoft.com/feedback
--------------------
| From: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vc
| Subject: Re: /clr option
| Lines: 442
|
| Here is what i got when i added /MD option:
|
| LINK : warning LNK4044: unrecognized option '/MD'; ignored
|
| MSVCMRT.lib(mstartup.obj) : error LNK2005: ___app_type already defined in
| LIBCMT.lib(crt0.obj)
|
| LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other
| libs; use /NODEFAULTLIB:library
|
| regadrs
|
| -sarab
|
|
| | > OK... here you're using /clr and you need to use the DLL version of the
| CRT
| > for this to work. Try compiling with \MD.
| >
| > Thanks for hanging in there with me!
| >
| >
| > Kang Su Gatlin
| > Visual C++ Program Manager
| >
| > File bugs in Visual Studio/.NET at:
| >
http://msdn.microsoft.com/feedback
| >
| > --------------------
| > | From: <
[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.vc
| > | References: <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <RhoyjE#
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <HX0#
[email protected]>
| > | Subject: Re: /clr option
| > | Lines: 346
| > |
| > | I did as you said and everything links ok but with one exception :
| > | Here is the link command and the error :
| > |
| > | c:/mks/mksnt/rm.exe -f dbspicam.exe
| > |
| > |
| >
|
Lib="/DBSPI/external/opc/lib/ito4/4.0WINNT;C:/Progra~1/MID05A~1/vc/lib;/Micr
| > |
| >
|
osoft/mssdk/lib;C:/Progra~1/MID05A~1/vc/../SDK/v2.0/lib;/Microsoft/mssdk/mis
| > | c/posix/lib" C:/Progra~1/MID05A~1/vc/bin/link.exe /INCREMENTAL\:NO
| > | /RELEASE /NOLOGO /RELEASE /INCREMENTAL\:NO /RELEASE /NOLOGO
| /RELEASE
| > | /SUBSYSTEM:CONSOLE nt_udm.o dbspiwhat.o lts_parser.o overlapctrl.o
| > | mwiface.o range.o udmy.o udml.o ../../dbspi_config/4.0WINNT/cfgy.o
| > | ../../dbspi_config/4.0WINNT/cfgl.o udm_ms.o cola_ms.o mdata_ms.o
| > | metrics_ms.o osm_ms.o itoiface_ms.o dbspicam.res
| > | ../../mssql_metrics/4.0WINNT/libmsmet.lib
| > ./../common/4.0WINNT/libovam.lib
| > | opcapi.lib libcmt.lib opcapi.lib ws2_32.lib advapi32.lib user32.lib
| > | /OUT:dbspicam.exe
| > | MSVCMRT.lib(mstartup.obj) : error LNK2005: ___app_type already defined
| in
| > | libcmt.lib(crt0.obj)
| > | LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of
other
| > | libs; use /NODEFAULTLIB:library
| > | dbspicam.exe : fatal error LNK1169: one or more multiply defined
symbols
| > | found
| > |
| > | i tried using /NODEFAULTLIB but it still complained about multiple
| > symbols.
| > | It seems one of these libs(advapi32.lib, user32.lib) is sucking in
| > | libcmt.lib.
| > |
| > |
| > | regards
| > | -sarab
| > |
| > |
| > |
| > |
| > | | > | > You should only hit this inconsistent definition problem when
compiled
| > | with
| > | > /clr. The yacc generated code you should just compile /TP, and
while
| I
| > | > believe this technically violates the One Definition Rule, it should
| be
| > | OK.
| > | >
| > | > Does this make sense?
| > | >
| > | > Thanks,
| > | >
| > | > ---
| > | > Kang Su Gatlin
| > | > Visual C++ Program Manager
| > | >
| > | > File bugs in Visual Studio/.NET at:
| > | >
http://msdn.microsoft.com/feedback
| > | >
| > | > --------------------
| > | > | From: <
[email protected]>
| > | > | Newsgroups: microsoft.public.dotnet.languages.vc
| > | > | Subject: Re: /clr option
| > | > | Lines: 257
| > | >
| > | > |
| > | > | I have 2 lines of .NET code in the file with some c code.
| > | > |
| > | > | #using <mscorlib.dll>
| > | > |
| > | > | Console::WriteLine("HEllo World");
| > | > | i kept it simple so that i can some thing working before i start
| > adding
| > | > | other code.
| > | > |
| > | > | Before i posted this message, i tried the first option and got
stuck
| > on
| > | > some
| > | > | code generated by yacc/lex.
| > | > | yacc/lex geneate a union and the compiler complained about its
| layout
| > | > being
| > | > | different.
| > | > |
| > | > | I would like to know how difficult this option is before i try
to
| go
| > | for
| > | > | option 1 because i am stuck either way.
| > | > |
| > | > | regards
| > | > | -sarab
| > | > |
| > | > |
| > | > | | > | > | > OK, it appears that you have some calls to these to these
| functions
| > as
| > | > | well
| > | > | > in your code. You could probably make this work, but it would
be
| a
| > | lot
| > | > | > more surgical. Try the /TP option, and remove the extern stuff
| you
| > | just
| > | > | > put in. The nice thing about going with /TP is that if you do
| need
| > to
| > | > | make
| > | > | > more of those files compile with /clr then you're already most
of
| > the
| > | > way
| > | > | > there.
| > | > | >
| > | > | > Thanks,
| > | > | >
| > | > | > Kang Su Gatlin
| > | > | > Visual C++ Program Manager
| > | > | >
| > | > | > --------------------
| > | > | > | From: <
[email protected]>
| > | > | > | Newsgroups: microsoft.public.dotnet.languages.vc
| > | > | >
| > | > | > | Subject: Re: /clr option
| > | > | >
| > | > | > |
| > | > | > | I took the second option and wrapped the C++ code with extern
| "C".
| > | > | > | I get the following errors during linking :
| > | > | > |
| > | > | > | libmsmet.lib(metric3020.o) : error LNK2001: unresolved
external
| > | symbol
| > | > | > | "?.cctor@
| > | > | > | @$$FYMXXZ" (?.cctor@@$$FYMXXZ)
| > | > | > | LINK : error LNK2001: unresolved external symbol
__CorExeMain@0
| > | > | > | dbspicam.exe : fatal error LNK1120: 2 unresolved externals
| > | > | > |
| > | > | > |
| > | > | > | In my last email, i was talking about calling C code from C++
| > which
| > | is
| > | > | ok.
| > | > | > |
| > | > | > | regards
| > | > | > | -sarab
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | > |
message
| > | > | > | | > | > | > | > OK, you're problem actually has to do with calling C++ from
C,
| > and
| > | > | > nothing
| > | > | > | > directly to do with /clr. To fix this you have at least two
| > | obvious
| > | > | > | > options:
| > | > | > | >
| > | > | > | > 1) Recompile your .c files with /TP (and fix the various
small
| > | > issues
| > | > | > that
| > | > | > | > come up there).
| > | > | > | > or
| > | > | > | > 2) Wrap your C++ functions with extern "C" { ... code here
| ...
| > }
| > | > | > | >
| > | > | > | > I'm not sure if I understand this latest question. You're
| > asking
| > | if
| > | > | you
| > | > | > | > can call C code from C code? I suspect it's not, so I'm
sure
| > I'm
| > | > | > missing
| > | > | > | > something.
| > | > | > | >
| > | > | > | > I hope this help. Let me know if this doesn't.
| > | > | > | >
| > | > | > | > Thanks!
| > | > | > | >
| > | > | > | > Kang Su Gatlin
| > | > | > | > Visual C++ Program Manager
| > | > | > | >
| > | > | > | >
| > | > | > | > | From: <
[email protected]>
| > | > | > | > | Newsgroups: microsoft.public.dotnet.languages.vc
| > | > | > | > | References: <
[email protected]>
| > | > | > | > <
[email protected]>
| > | > | > | > <
[email protected]>
| > | > | > | > <
[email protected]>
| > | > | > | > <
[email protected]>
| > | > | > | > | Subject: Re: /clr option
| > | > | > | > | Date: Wed, 11 Aug 2004 18:44:12 GMT
| > | > | > | >
| > | > | > | > | Hi ,
| > | > | > | > | Also, i forgot to mention one thing.
| > | > | > | > | I also want to know what i need to do so that i can call C
| > | > functions
| > | > | > | from
| > | > | > | > | a.c.
| > | > | > | > | e.g.
| > | > | > | > | There is a function g() defined in a.c and a function h()
| > | defined
| > | > in
| > | > | > | > main.c.
| > | > | > | > | can i call h() from g() without having to do anything
| special.
| > | > | > | > | All the code in our product is C code (no COM).
| > | > | > | > |
| > | > | > | > | I appreciate your help in this regard.
| > | > | > | > |
| > | > | > | > | regards
| > | > | > | > | -sarab
| > | > | > | > |
| > | > | > | > |
| > | > | > | > |
| > | > | > | > | | > | > | > | > | > When i remove the /clr and /TP option, it links ok (i
had
| to
| > | > | comment
| > | > | > | all
| > | > | > | > | the
| > | > | > | > | > .NET code for this to link).
| > | > | > | > | > You are correct, the rest of the code is C.
| > | > | > | > | > So, here is what i have.
| > | > | > | > | >
| > | > | > | > | > The C code(main.c) calls a function f() which lives in
| the
| > | file
| > | > | > a.c.
| > | > | > | > The
| > | > | > | > | > file a.c has .NET code and it has to be compiled with
/clr
| > and
| > | > /TP
| > | > | > | > | > option.
| > | > | > | > | > The file main.c has c code and is compiled without /clr
| and
| > | /TP
| > | > | > | option.
| > | > | > | > | >
| > | > | > | > | > How do i resolve the unresolved symbol f() during
| linking?.
| > | > | > | > | >
| > | > | > | > | > -sarab
| > | > | > | > | >
| > | > | > | > | >
| > | message
| > | > | > | > | > | > | > | > | > | > > No, there is nothing you need to do. Try to remove
the
| > | '/clr'
| > | > | > | option
| > | > | > | > | only
| > | > | > | > | > > (leave every other compiler switch the same) and see
if
| > you
| > | > | still
| > | > | > | get
| > | > | > | > | the
| > | > | > | > | > > unresolved symbols issue (the /TP you mention makes me
| > | > suspcious
| > | > | > | that
| > | > | > | > | the
| > | > | > | > | > > rest of your code is in 'C') . If you don't, could
you
| > see
| > | if
| > | > | you
| > | > | > | can
| > | > | > | > | put
| > | > | > | > | > > together a simple repro with this behavior.
| > | > | > | > | > >
| > | > | > | > | > > Thanks!
| > | > | > | > | > >
| > | > | > | > | > > Kang Su Gatlin
| > | > | > | > | > > Visual C++ Program Manager
| > | > | > | > | > >
| > | > | > | > | > >
| > | > | > | > | > > --------------------
| > | > | > | > | > > | From: <
[email protected]>
| > | > | > | > | > > | Newsgroups: microsoft.public.dotnet.languages.vc
| > | > | > | > | > > | References: <
[email protected]>
| > | > | > | > | > > <
[email protected]>
| > | > | > | > | > > | Subject: Re: /clr option
| > | > | > | > | > >
| > | > | > | > | > > |
| > | > | > | > | > > | Now, i have one file which has all the .NET code and
| it
| > is
| > | > | being
| > | > | > | > | > compiled
| > | > | > | > | > > | with /clr /TP option.
| > | > | > | > | > > | During linking, i get unresolved symbol for the
| > function
| > | > | > defined
| > | > | > | in
| > | > | > | > | the
| > | > | > | > | > > | file.
| > | > | > | > | > > |
| > | > | > | > | > > | is there anything special that i need to do so that
| the
| > | > | > functions
| > | > | > | in
| > | > | > | > | the
| > | > | > | > | > > | file are visible to the rest of the code?.
| > | > | > | > | > > |
| > | > | > | > | > > |
| > | > | > | > | > > | regards
| > | > | > | > | > > | -sarab
| > | > | > | > | > > |
| > | > | > | > | > > |
| in
| > | > | message
| > | > | > | > | > > | | > | > | > | > | > > | > No, only those that use .NET classes (in fact you
| can
| > | use
| > | > | more
| > | > | > | > fine
| > | > | > | > | > > | > granularity than libraries, and do it at the file
or
| > | > | function
| > | > | > | > level,
| > | > | > | > | > > using
| > | > | > | > | > > | > #pragma unmanaged).
| > | > | > | > | > > | >
| > | > | > | > | > > | > Give it a shot, and if you hit any problems,
please
| > | post
| > | > | back
| > | > | > | > here.
| > | > | > | > | > > | >
| > | > | > | > | > > | > Thanks,
| > | > | > | > | > > | >
| > | > | > | > | > > | > Kang Su Gatiln
| > | > | > | > | > > | > Visual C++ Program Manager
| > | > | > | > | > > | >
| > | > | > | > | > > | > --------------------
| > | > | > | > | > > | > | From: <
[email protected]>
| > | > | > | > | > > | > | Newsgroups: microsoft.public.dotnet.languages.vc
| > | > | > | > | > > | > | Subject: /clr option
| > | > | > | > | > > | >
| > | > | > | > | > > | > | Hi ,
| > | > | > | > | > > | > | We have a lot of code which runs fine under
| VC++
| > | > 6.0.
| > | > | We
| > | > | > | > have
| > | > | > | > | to
| > | > | > | > | > > | move
| > | > | > | > | > > | > to
| > | > | > | > | > > | > | .NET becasue one of the librairies uses .NET
| > classes.
| > | > | > | > | > > | > |
| > | > | > | > | > > | > | Does every library(including those which do not
| use
| > | .NET
| > | > | > | > classes)
| > | > | > | > | > > have
| > | > | > | > | > > | > to
| > | > | > | > | > > | > | be recompiled with /clr option?.
| > | > | > | > | > > | > |
| > | > | > | > | > > | > |
| > | > | > | > | > > | > | regards
| > | > | > | > | > > | > | -sarab
| > | > | > | > | > > | > |
| > | > | > | > | > > | > |
| > | > | > | > | > > | > |
| > | > | > | > | > > | >
| > | > | > | > | > > |
| > | > | > | > | > > |
| > | > | > | > | > > |
| > | > | > | > | > >
| > | > | > | > | >
| > | > | > | > | >
| > | > | > | > |
| > | > | > | > |
| > | > | > | > |
| > | > | > | >
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|