Page 1 of 1

No wxmsw28ud_adv.lib for link step

Posted: Mon Jan 29, 2007 10:25 pm
by dejudicibus
I just moved from Borland C++Builder 5.5 to Visual Studio 2005 Express. I was able to build wxWidgets, but now I have a problem building my own application. Please, note that my application is a Unicode one.

Compile is ok, but as I try to link I get

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

If I look at \wxWidgets\lib\vc_lib I can see five files containing _adv:

wxmsw28d_adv.lib
wxmsw28d_adv.idb
wxmsw28u_adv.idb
wxmsw28ud_adv.idb
wxmsw28ud_adv.pdb

Is that correct? It looks like there is no wxmsw28ud_adv.lib, but to my (little) understanding of VS it looks like idb files are an extension of corresponding lib files. Is that correct? What I have to do?

Re: No wxmsw28ud_adv.lib for link step

Posted: Mon Jan 29, 2007 10:48 pm
by benedicte
dejudicibus wrote:It looks like there is no wxmsw28ud_adv.lib, but to my (little) understanding of VS it looks like idb files are an extension of corresponding lib files. Is that correct? What I have to do?
No, you're wrong.

You must have .lib files even when compiling with Visual Studio.

Now, try to do this:
Open the wxwidgets solution with Visual Studio.
Choose the configuration you need ("DLL Unicode Debug" or something like that)
Build the "adv" project (only the project).
What is the result you get?
If the library is built correctly, then build them all.
And then build your app.

Posted: Mon Jan 29, 2007 11:47 pm
by dejudicibus
OK, it worked. Now I have all UD lib files. However link still does not work. My fault, ofcourse, since I am new to VS and it is not so easy to migrate at the same time from wxw 2.6.2 + bcc 5.5 to wxw 2.8.0 + vs 2500 express.

I have a lot of warnings like this:

wxbase28ud.lib(tarstrm.obj) : warning LNK4049: locally defined symbol _free imported

or this:

wxmsw28ud_core.lib(mdi.obj) : warning LNK4049: locally defined symbol _wcscmp imported

plus errors like this:

wxbase28ud.lib(fmapbase.obj) : error LNK2001: unresolved external symbol __imp__swscanf

I assume that it is a matter of which libs I use and which I exclude. Here is my choice. I assume it is wrong:

ADDITIONAL DEPENDENCIES
wxmsw28ud_xrc.lib
wxmsw28ud_aui.lib
wxmsw28ud_adv.lib
wxmsw28ud_html.lib
wxbase28ud_xml.lib
wxmsw28ud_core.lib
wxbase28ud.lib
wxtiffd.lib
wxjpegd.lib
wxpngd.lib
wxzlibd.lib
wxregexud.lib
wxexpatd.lib
kernel32.lib
user32.lib
gdi32.lib
comdlg32.lib
winspool.lib
winmm.lib
shell32.lib
comctl32.lib
ole32.lib
oleaut32.lib
uuid.lib
rpcrt4.lib
advapi32.lib
wsock32.lib
odbc32.lib

IGNORE SPECIFIC LIBRARIES
MSVCRTD.LIB;MSVCRT.LIB

IGNORE ALL DEFAULT LIBRARIES
no

My application is Unicode Debug with MSLU and static libraries (no DLLs)
Any help appreciated. Thank you in advance.

Posted: Tue Jan 30, 2007 3:48 am
by biplab
The errors you are getting is due to linking of improper C Runtime Libraries (CRT). Assuming you didn't change CRT settings of wxWidgets, your application shall be linked against msvcrtd.lib; but not libcmtd.lib. Also you should compile your application using /MDd in debug mode and /MD in release mode.

For debug target, add /NODEFAULTLIB:libcmtd.lib and /NODEFAULTLIB:msvcrt.lib (this one to avoid few wanings) and add msvcrtd.lib in the list of libraries.

For release target, add /NODEFAULTLIB:libcmt.lib. This would solve the problem.

Alternatively if you wish to use, BCC 5.5.1 or BCC 5.82 (Compiler that comes with Turbo C++ Explorer) or MSVC or GCC compiler for your wxWidgets project then please read my blog and download the latest wxWidgets Project wizard (http://biplab.wordpress.com/2007/01/29/ ... odeblocks/). Installation instruction is available in my blog.

Hope this helps. :)

Posted: Tue Jan 30, 2007 9:01 am
by dejudicibus
biplab wrote:The errors you are getting is due to linking of improper C Runtime Libraries (CRT). Assuming you didn't change CRT settings of wxWidgets, your application shall be linked against msvcrtd.lib; but not libcmtd.lib. Also you should compile your application using /MDd in debug mode and /MD in release mode.
Why /MDd? I do not want to generate DLL, but create an exe statically linked with wxWidgets. I thought I should use /MTd...

Posted: Tue Jan 30, 2007 9:37 am
by biplab
dejudicibus wrote: Why /MDd? I do not want to generate DLL, but create an exe statically linked with wxWidgets. I thought I should use /MTd...
You can create statically linked app with wxWidgets even with /MDd or /MD option. The options instructs the compiler on how to link the C Runtime Library (CRT) against your application. So if you are using /MDd option, your application will depend upon msvcrt.dll whereas using /MTd will remove this dependency.

Statical linking of CRT is not recommended with MSVC compilers while using it for wxWidgets. wxWidgets based applications when statically linked will have performance issues with wxString. Read the following code snippets from wxWidgets source.

src/common/string.cpp

Code: Select all

// ===========================================================================
// wxStringData class deallocation
// ===========================================================================

#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL)
#  pragma message (__FILE__ ": building with Multithreaded non DLL runtime has a performance impact on wxString!")
void wxStringData::Free()
{
    free(this);
}
#endif
Regards,

Biplab :)

Posted: Tue Jan 30, 2007 9:13 pm
by dejudicibus
biplab wrote:
dejudicibus wrote: ... So if you are using /MDd option, your application will depend upon msvcrt.dll whereas using /MTd will remove this dependency....
Well, if so I have to ship msvcrt.dll with my code... Can I? Should I? And where can I take it from?

Posted: Wed Jan 31, 2007 1:31 am
by biplab
dejudicibus wrote:
biplab wrote:
dejudicibus wrote: ... So if you are using /MDd option, your application will depend upon msvcrt.dll whereas using /MTd will remove this dependency....
Well, if so I have to ship msvcrt.dll with my code... Can I? Should I? And where can I take it from?
The dll should be present in most of the Windows systems. I don't know the legal implications. But AFAIK you may not be allowed to redistribute it. But you can advice your user to download the dll from the following link, if they don't have it in their system.
Regards,

Biplab

Posted: Wed Jan 31, 2007 3:13 pm
by dejudicibus
biplab wrote: The dll should be present in most of the Windows systems. I don't know the legal implications. But AFAIK you may not be allowed to redistribute it. But you can advice your user to download the dll from the following link, if they don't have it in their system.
Regards,

Biplab
Acc... Are you telling me that ALL my users have to have a connection to Internet to download a file? That they canno simply use my application as is? I REALLY do not like that. My application, up to now, was a freeware very easy and fast to install. No skill required. I wonder if moving from Borland to Visual Studio was a good idea :(

Posted: Wed Jan 31, 2007 5:16 pm
by biplab
dejudicibus wrote: Acc... Are you telling me that ALL my users have to have a connection to Internet to download a file? That they canno simply use my application as is? I REALLY do not like that. My application, up to now, was a freeware very easy and fast to install. No skill required. I wonder if moving from Borland to Visual Studio was a good idea :(
I understand your feeling.

If you notice all the major companies distribute necessary dlls with their package. They can afford to license the files from the manufacturer.

For small freeware developers, this could be an issue. You can directly ask Microsoft officials regarding this licensing issue.

IMHO, getting into legal hassles is not good when you can simply point to the source without any problem.

Take this case. If I develop a .NET based app, I have to ask the user to download the full runtime (if they don't have it) as I'm not supposed to redistribute them without permission. May be my application is just 50 kb but you need to download 20MB+ to run it.

So post your app without the CRT. Let users download CRT package if they don't have it. That's a one time investment for users. You are also free from any legal hassles.

AFAIK, with latest updates, the CRTs get installed in most of the PCs (Even in different Win Versions). So I don't think it will be a big issue.

Posted: Wed Jan 31, 2007 10:56 pm
by dejudicibus
Thank you for suggestions. I think I will ask MS the permission to ship their dll's. Since mine is freeware, I do not think they can be damaged by that. Thank you.