FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compiling + Linking Weirdness

 
Post new topic   Reply to topic     Forum Index -> Visual D
View previous topic :: View next topic  
Author Message
awishformore



Joined: 03 Sep 2008
Posts: 17

PostPosted: Thu Jun 24, 2010 5:16 am    Post subject: Compiling + Linking Weirdness Reply with quote

Hello there.

I ran into some more issues with Visual D that are really confusing me. For reproduction of the issues, I wrote this code bit:

Code:
module main;

import enet;

int main(char[][]argv)
{
   enet_initialize();
   enet_deinitialize();

   return 0;
}


This, of course, doesn't work unless I add the import path of my enet binding (using dnet from dsource, works fine). I thus add the path

Code:
C:\code\enet\include

to "Additional Imports".

The app compiles fine now, but obviously the linking still doesn't work.

Obviously I have to add the libs. According to the README, I need winmm.lib and ws2_32.lib on Windows, as well as enet.lib, of course. I thus add

Code:
winmm.lib ws2_32.lib enet.lib

to "Library Files".

Of course, the compiler also needs to know where to find enet.lib, so I add

Code:
C:\code\enet\Debug

to "Library Search Path".

And now, it should link, right?

Unfortunately it doesn't:

Code:
enet.lib
 Warning 2: File Not Found enet.lib
Debug\ConsoleApp1.obj(ConsoleApp1)
 Error 42: Symbol Undefined _enet_initialize
Debug\ConsoleApp1.obj(ConsoleApp1)
 Error 42: Symbol Undefined _enet_deinitialize
--- errorlevel 2
Building Debug\ConsoleApp1.exe failed!


I double-checked that all files are where they should be, and they are.

To add to the weirdness, if I change the libraries to

Code:
winmm.lib ws2_32.lib C:\code\enet\Debug\enet.lib


...it works fine, even without library paths added and I find my executable in the <project>/Debug folder.

I'm pretty sure that I shouldn't need to put the complete path into the libraries field.


But it gets even more strange. I do the exact same configuration for the Release build - "C:\code\enet\include" into the import paths, "winmm.lib ws2_32.lib C:\code\enet\Release\enet.lib" for libraries. I compile my project as Release build, and certainly enough, there are no errors and the build is successfully completed.

I navigate to the <project>/Release folder and...there is no executable? What the hell is going on now? To check whether it goes into the Debug folder, even though it shouldn't, I delete my Debug executable and compile the Release configuration again. Nope. No executable in the Debug folder either. Where could the executable possibly have gone?

I search my entire system for <project>.exe, but there is no match. The Release configuration correctly builds and links everything, but there is no executable to be found anywhere. The build log doesn't really help either:

Code:
Build Log

Building Release\ConsoleApp1.exe

Command Line

set PATH=C:\code\dmd2\windows\bin;C:\code\Microsoft SDKs\Windows\v7.0\\bin;%PATH%
dmd -release -IC:\code\enet\include -of"Release\ConsoleApp1.exe" -deps="Release\ConsoleApp1.dep" -map "Release\ConsoleApp1.map" -L/NOMAP winmm.lib ws2_32.lib C:\code\enet\Release\enet.lib main.d
:xit
if errorlevel 1 echo Building Release\ConsoleApp1.exe failed!
Output


Nothing is recorded at all.

To be complete, here is the build log for the Debug configuration without the complete path in the library field and with the Library Search Path correctly set (the configuration that doesn't work):

Code:
Build Log 
Building Debug\ConsoleApp1.exe 
Command Line 
set PATH=C:\code\dmd2\windows\bin;C:\code\Microsoft SDKs\Windows\v7.0\\bin;%PATH%
set LIB=;C:\code\enet\Debug\;%LIB%
dmd -g -debug -IC:\code\enet\include -of"Debug\ConsoleApp1.exe_cv" -deps="Debug\ConsoleApp1.dep" -map "Debug\ConsoleApp1.map" -L/NOMAP winmm.lib ws2_32.lib enet.lib main.d
if errorlevel 1 goto xit
echo Converting debug information...
"C:\code\VisualD\cv2pdb\cv2pdb.exe" -D2 "Debug\ConsoleApp1.exe_cv" "Debug\ConsoleApp1.exe"
:xit
if errorlevel 1 echo Building Debug\ConsoleApp1.exe failed!
Output 
OPTLINK (R) for Win32  Release 8.00.2
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
enet.lib
 Warning 2: File Not Found enet.lib
Debug\ConsoleApp1.obj(ConsoleApp1)
 Error 42: Symbol Undefined _enet_initialize
Debug\ConsoleApp1.obj(ConsoleApp1)
 Error 42: Symbol Undefined _enet_deinitialize
--- errorlevel 2
Building Debug\ConsoleApp1.exe failed!


Seems to me like it should work. And here is the build log without Library Search Path, but with the entire library path added to the library field (the working configuration):

Code:
Build Log

Building Debug\ConsoleApp1.exe

Command Line

set PATH=C:\code\dmd2\windows\bin;C:\code\Microsoft SDKs\Windows\v7.0\\bin;%PATH%
dmd -g -debug -IC:\code\enet\include -of"Debug\ConsoleApp1.exe_cv" -deps="Debug\ConsoleApp1.dep" -map "Debug\ConsoleApp1.map" -L/NOMAP winmm.lib ws2_32.lib C:\code\enet\Debug\enet.lib main.d
if errorlevel 1 goto xit
echo Converting debug information...
"C:\code\VisualD\cv2pdb\cv2pdb.exe" -D2 "Debug\ConsoleApp1.exe_cv" "Debug\ConsoleApp1.exe"
:xit
if errorlevel 1 echo Building Debug\ConsoleApp1.exe failed!
Output

Converting debug information...



And last but not least, if I manually delete the <project>.exe_cv file and try to build, rebuild or rebuild/build with previous clean, I get the following build log:

Code:
Command Line

set PATH=C:\code\dmd2\windows\bin;C:\code\Microsoft SDKs\Windows\v7.0\\bin;%PATH%
dmd -g -debug -IC:\code\enet\include -of"Debug\ConsoleApp1.exe_cv" -deps="Debug\ConsoleApp1.dep" -map "Debug\ConsoleApp1.map" -L/NOMAP winmm.lib ws2_32.lib C:\code\enet\Debug\enet.lib main.d
if errorlevel 1 goto xit
echo Converting debug information...
"C:\code\VisualD\cv2pdb\cv2pdb.exe" -D2 "Debug\ConsoleApp1.exe_cv" "Debug\ConsoleApp1.exe"
:xit
if errorlevel 1 echo Building Debug\ConsoleApp1.exe failed!
Output

Converting debug information...
Debug\ConsoleApp1.exe_cv: Can't open file
Building Debug\ConsoleApp1.exe failed!


I then have to delete the project and create it from scratch in order to get it to compile again.


All of these issues together currently make me strongly reconsider going back to another IDE, but unfortunately, there is no real alternative for D (at least not in my humble opinion). I would appreciate it so much if you could get at least some of that stuff fixed as I would really like to work with Visual D in the future.

I hope I could provide some valuable feedback once more.

Take care, Max.
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Thu Jun 24, 2010 3:21 pm    Post subject: Reply with quote

Hi,

Quote:
...it works fine, even without library paths added and I find my executable in the <project>/Debug folder.

I'm pretty sure that I shouldn't need to put the complete path into the libraries field.


Unfortunately, it is impossible to pass a library search path to the linker through dmd with the standard installation. Optlink only accepts the path in the LIB environment variable (this is set by Visual D), but dmd overwrites it with the settings in its configuration file sc.ini.

You should change the LIB setting in dmd2\windows\bin\sc.ini to this:
Code:
LIB="%@P%\..\lib";\dm\lib;%LIB%


Quote:
But it gets even more strange. I do the exact same configuration for the Release build - "C:\code\enet\include" into the import paths, "winmm.lib ws2_32.lib C:\code\enet\Release\enet.lib" for libraries. I compile my project as Release build, and certainly enough, there are no errors and the build is successfully completed.

I navigate to the <project>/Release folder and...there is no executable? What the hell is going on now?
...
Nothing is recorded at all.


I cannot really explain what is happening, but here are some thoughts:
- The empty output could mean that it compiled without errors.
- I've onced encountered a problem with an empty dependency file (ConsoleApp1.dep) that caused Visual D to never rebuild, but that should be fixed by a clean or a deletion of the output folder.
- Deleting the *.exe_cv file should not change a lot, because it is just an intermediate file. You should delete the *.exe file (if it is there) to force a rebuild.
- Do you have some unusual characters in your project directory path? Maybe there is some problem with setting the working directory.

Thanks for taking the time to report.

Rainer
Back to top
View user's profile Send private message
awishformore



Joined: 03 Sep 2008
Posts: 17

PostPosted: Thu Jun 24, 2010 3:55 pm    Post subject: Reply with quote

sagitario wrote:
You should change the LIB setting in dmd2\windows\bin\sc.ini to this:
Code:
LIB="%@P%\..\lib";\dm\lib;%LIB%



OK, that explains that Wink.

Quote:
But it gets even more strange. I do the exact same configuration for the Release build - "C:\code\enet\include" into the import paths, "winmm.lib ws2_32.lib C:\code\enet\Release\enet.lib" for libraries. I compile my project as Release build, and certainly enough, there are no errors and the build is successfully completed.

I navigate to the <project>/Release folder and...there is no executable? What the hell is going on now?
...
Nothing is recorded at all.


Quote:
- The empty output could mean that it compiled without errors.


As I said, it does indeed compile without errors - at least that's what the message window tells me. But there is no executable, which kindof cancels the benefit of an error-free compilation Wink.

Quote:
- I've onced encountered a problem with an empty dependency file (ConsoleApp1.dep) that caused Visual D to never rebuild, but that should be fixed by a clean or a deletion of the output folder.


That didn't help at all and my issue is reproducible for me any time on any project.

Quote:
- Deleting the *.exe_cv file should not change a lot, because it is just an intermediate file. You should delete the *.exe file (if it is there) to force a rebuild.


I tried first deleting only the executable, but it still didn't work. I _then_ deleted the entire output folder. That's when the compile stopped working because of a missing .exe_cv file. I know it should only be a temporary file, but it doesn't recreate it and then expects it to be there, so the compile fails.

Quote:
- Do you have some unusual characters in your project directory path? Maybe there is some problem with setting the working directory.


Nope. I can reproduce this in any project under any name, unfortunately.

Hope I could clear it up.

Greetings, Max.
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Fri Jun 25, 2010 10:42 am    Post subject: Reply with quote

Hi,

Quote:
Nope. I can reproduce this in any project under any name, unfortunately.


The commands executed are written into a batch file named <ProjectName>.build.cmd in the output directory.

To see whats going on, you can try executing it from the command line with the working directory being the project directory.

Rainer
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Visual D All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group