Author Topic: Library directories are not in the linker path for new compiler  (Read 6343 times)

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
I have create a new compiler for MASM32 nad so far it works. The only problem I have is, that the library directory is not passed to the linker out of the box.

When I add the library path manually, it works but not when I create a new project. So what do I have to setup for that?

My compiler XML looks like this:
Code
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_compiler>
<CodeBlocks_compiler name="MASM 32/64"
                     id="masm"
                     weight="60">
    <Path type="master">
        <Search envVar="PATH"
                for="ml.exe"/>
        <if platform="windows">
            <Search path="C:\MASM32"/>
            <Fallback path="C:\MASM32"/>
        </if>
        <if platform="windows">
            <Search path="D:\MASM32"/>
            <Fallback path="D:\MASM32"/>
        </if>
    </Path>
<Path type="include">
<Add><master/>\include</Add>
</Path>
    <Path type="lib">
        <Add><master/>\lib</Add>
    </Path>
</CodeBlocks_compiler>

As I understood it, that add/master should add the path of the directory "\lib" and prepend the master directory (the installation path), right?

In the options XML I have the following:

Code
    <Switch name="includeDirs"             value="/I"/>
    <Switch name="libDirs"                 value="/LIBPATH:"/>
    <Switch name="linkLibs"                value=""/>
    <Switch name="defines"                 value="/D"/>
    <Switch name="genericSwitch"           value="/"/>
    <Switch name="objectExtension"         value="obj"/>
    <Switch name="needDependencies"        value="false"/>
    <Switch name="forceCompilerUseQuotes"  value="false"/>
    <Switch name="forceLinkerUseQuotes"    value="false"/>
    <Switch name="logging"                 value="default"/>
    <Switch name="libPrefix"               value=""/>
    <Switch name="libExtension"            value="lib"/>
    <Switch name="linkerNeedsLibPrefix"    value="false"/>
    <Switch name="linkerNeedsLibExtension" value="true"/>

...

    <Command name="CompileObject"
             value="$compiler /nologo $options $includes /Fo $object /c $file "/>
    <Command name="CompileResource"
             value="$rescomp $res_includes -fo$resource_output $file"/>
    <Command name="LinkExe"
             value="$linker /nologo /subsystem:windows $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkConsoleExe"
             value="$linker /nologo $libdirs /subsystem:console /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkDynamic"
             value="$linker /dll /nologo $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkStatic"
             value="$lib_linker /lib /nologo $libdirs /out:$static_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkNative"
             value="$linker /nologo /subsystem:native $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>

So I would have epxected that "$libdirs" should substitute for the given paths. But it seems like it is doing this only for manually added paths, that I add in the build options dialog, but not the paths that should have been added as the project defauls. Is this a bug, or am I missing something here? The library themselve (kernel32.lib), which I also added via the project wizard is showing up ($libs), but the path is missing.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Library directories are not in the linker path for new compiler
« Reply #1 on: March 23, 2014, 12:01:52 pm »
But it seems like it is doing this only for manually added paths, that I add in the build options dialog, but not the paths that should have been added as the project defauls.
What do you mean by project defaults here?
If you don't see it in the build option or the global compiler options, then it won't be passed to the compiler/linker.
C::B tries to do as little magical things as possible!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Library directories are not in the linker path for new compiler
« Reply #2 on: March 23, 2014, 02:09:13 pm »
I created a wizard, which creates a MASM project. In the wizard I have the following line:

Code
function SetupProject(project)
{
    project.AddLinkLib(_T("kernel32"));
   ....
}

when I look in the generated project, I expected that the kernel32 library would be listed in the library section of the build option dialog, but it isn't. So I thought that maybe the way this library is added, is by some other mechanism i.e. the projects default settings created by the wizard. Because on the linker commandline I can see that the library is there, only the path is missing.

Actually I don't really like this, because I figure that it should be possible to modify this settings as well, but I haven't found any place in the dialog where this is stored.

In the build option dialog there is this box saying "Append target options to project options" which indicates to me that there shoul dbe some global project options (where I would expect the kernel32.lib to be found) and local options for that specific target (i.e. Debug, Release, etc.). But I can't find any global project options, which may well be because I'm still rather new to CB and don't know all the details.

As an exmaple, when I create the project with the wizard the linker commandline looks like this:

Code
link.exe /nologo  /subsystem:console /out:Debug\test.exe kernel32.lib Debug\obj\main.obj  /DEBUG 

But it should be like this:

Code
link.exe /nologo /LIBPATH:D:\Programme\masm32\lib /subsystem:console /out:Debug\test.exe kernel32.lib Debug\obj\main.obj  /DEBUG 

And I only get the "/LIBPATH" switch, when I add the path manually in the target library, but not from the wizard. So I would like to know what I do wrong here.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Library directories are not in the linker path for new compiler
« Reply #3 on: March 23, 2014, 04:00:33 pm »
1. The code you're using adds the lib to the project's options. Probably you're looking at the Target's options. Project -> Build options -> Click on the root of the tree on the left
2. Adding a library doesn't add the path to search for it. You have to use separate call. Check out other scripts for examples.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]