Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
Forum Updated to NodeBB v4.3 + New Features

LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 22.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TortugaRanger
    wrote on last edited by
    #1

    Hi,

    Although I've programmed quite a bit with Pascal (Embarcadero/MikroE) I'm new to Visual C++ and QT so my problem is probably quite simple to correct but apparently nearly impossible for this newbie to figure out on his own based on the past 24 hours of lost time getting nowhere.

    I have an existing windows application developed in QT with Visual c++ 2010 compiler/linker. I need to make some minor changes. I've got QT Creator up and running and working with Visual c++ 2010. So far so good.

    When I build the program I get several link error msgs which are basically summarized in the title to this post.

    I've spent hours and hours scouring the web for info on what's going on here and while I've certainly learned a lot it's not enough to correct this problem and move on.

    At this point I'm less interested in a broad tutorial on what this error msg means (I kind of get it based on searches). What I need is detailed hand holding on what to do to fix it. Dare I say it, I'm even willing to PAY SOMEONE to help me sort this out so I can move forward.

    Sleepless in South Florida (a.k.a. Morten)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      ScottR
      wrote on last edited by
      #2
      1. You should ask the author of the existing application how he/she managed to get it to link. If you made changes before getting it to build, back out those changes and get it to build first, without changing anything.

      2. Select the project that is failing. Right-click, choose "Properties". Under "Configuration Properties", expand the "Linker" node. Under "Linker" select "Input". On the right hand side of the tab you will see an entry labelled "Ignore specific default libraries". Add MSVCRT to that entry.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TortugaRanger
        wrote on last edited by
        #3

        [quote author="ScottR" date="1387308939"]1) You should ask the author of the existing application how he/she managed to get it to link. If you made changes before getting it to build, back out those changes and get it to build first, without changing anything.

        1. Select the project that is failing. Right-click, choose "Properties". Under "Configuration Properties", expand the "Linker" node. Under "Linker" select "Input". On the right hand side of the tab you will see an entry labelled "Ignore specific default libraries". Add MSVCRT to that entry.[/quote]

        The project/source code is from a Microchip website so getting to the author isn't practical.

        I've made no changes to the code. I'm just trying to compile/link it as is which is when this fun started.

        To be clear, this is a QT project (*.pro), not a Visual c++ project. QT Creator uses Visual c++ 2010 as its compiler. So unless I'm more confused than I already think I am, going to Visual c++ to tweak properties of a project that's not under Visual c++ isn't going to work out so well. Don't I have to find a way to modify the *.pro file so qmake will have the correct configuration info to pass to the v++ compiler?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          ScottR
          wrote on last edited by
          #4

          Did you try QMAKE_LFLAGS += /NODEFAULTLIB:MSVCRT?

          I have only used VS2010, not creator, so I'm not sure if this will work or not.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi and welcome to devnet,

            Add this to your pro file and you should be good to go

            @QMAKE_LFLAGS +=
            "/nodefaultlib: name_of_the_lib_you_want_to_ignore.lib"@

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • T Offline
              T Offline
              TortugaRanger
              wrote on last edited by
              #6

              I've tried numerous variations on "/nodefaultlib: ______" and also setting the /MT or /MD flags to no avail. Nothing changes the results.

              Here is what I get every time I build.

              link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST /MANIFESTFILE:windows\HIDBootloader.exe.embed.manifest /OUT:windows\HIDBootloader.exe @C:\Users\Morten\AppData\Local\Temp\HIDBootloader.exe.1340.2964.jom
              MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
              MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
              MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMT.lib(memmove.obj)
              MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
              MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
              Creating library windows\HIDBootloader.lib and object windows\HIDBootloader.exp
              LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
              windows\HIDBootloader.exe : fatal error LNK1169: one or more multiply defined symbols found

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dogbear
                wrote on last edited by
                #7

                @TortugaRanger:
                Hi. I know it's been a year since you last posted your problem.
                I do not have a solution but I am having the same issues.
                I was just wondering if you had found a solution to the "already defined" linker errors?
                Thanks

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dogbear
                  wrote on last edited by
                  #8

                  @TortugaRanger:
                  Hi. I know it's been a year since you last posted your problem.
                  I do not have a solution but I am having the same issues.
                  I was just wondering if you had found a solution to the "already defined" linker errors?
                  Thanks

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    karl_qt
                    wrote on last edited by
                    #9

                    "MSVCRT" is the runtime library of Visual Studio. Basically there are two versions of this code, a static linked (libcmt) one and a dynamic linked one (msvcrt), because you can link your application static or dynamic. ("Example for VS2013":http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx ) This can be changed in the project properties.
                    You are getting those message, e.g. if you have a statically linked programm, that uses an external library, which uses dynamically linked runtime code or vice versa. Then you have the same code twice and the linker reports an error.
                    If it is possible, stay with one kind of code generation. Otherwise you have to try out, what will work for you. You can change your software between static and dynamic. You can ignore libraries and add different libraries. Even the order of the libraries does matter.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      karl_qt
                      wrote on last edited by
                      #10

                      "MSVCRT" is the runtime library of Visual Studio. Basically there are two versions of this code, a static linked (libcmt) one and a dynamic linked one (msvcrt), because you can link your application static or dynamic. ("Example for VS2013":http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx ) This can be changed in the project properties.
                      You are getting those message, e.g. if you have a statically linked programm, that uses an external library, which uses dynamically linked runtime code or vice versa. Then you have the same code twice and the linker reports an error.
                      If it is possible, stay with one kind of code generation. Otherwise you have to try out, what will work for you. You can change your software between static and dynamic. You can ignore libraries and add different libraries. Even the order of the libraries does matter.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved