DLL Building in VS2012 - no DLL file appears - c++

In VS 2012, I start a DLL library project, add some code, hit Build and no DLL appears.
I know there are similar questions here on SO about the same topic, however
I have checked the output folder (set to the implicit *$(SolutionDir)$(Configuration)*)
Have not confused Debug and Release
etc..
The output folder does contain something after the build - a .lastbuildstate file and a .log file.
The content of the .lastbuildstate file is
#v4.0:v110:false
Debug|Win32|D:\Desktop\newOne\|
while the contents of the .log file is
Build started 16.10.2014 12:28:52.
1>Project "D:\Desktop\newOne\newOne.vcxproj" on node 2 (Build target(s)).
1>InitializeBuildStatus:
Creating "Debug\newOne.unsuccessfulbuild" because "AlwaysCreate" was specified.
FinalizeBuildStatus:
Deleting file "Debug\newOne.unsuccessfulbuild".
Touching "Debug\newOne.lastbuildstate".
1>Done Building Project "D:\Desktop\newOne\newOne.vcxproj" (Build target(s)).
Build succeeded.
Time Elapsed 00:00:00.02
I tried to create another DLL project from scratch, with the same code, and the result is the same.
Any help is much appreciated.
Daniel

Well in most cases people do look in the wrong directories (like in this issue) but usually the build log states the outputs but your log seems to be empty. What I would advice:
1) Check if your dll actually exports any symbols (functions/classes) - I am not actually sure if VS2012 generates the dll depending on the presence of exported symbols, but still
2) If you are build the whole solution not just the project check that the DLL project is actually marked to be built (a small chance but still)
UPDATE
I checked that symbol exports do not affect the producing of a dll - I set up an empty project and added some functions that are not exported and still got a normal build log:
1>------ Build started: Project: EmptyDllTest, Configuration: Debug Win32 ------
1> Source.cpp
1> EmptyDllTest.vcxproj -> c:\users\user\documents\visual studio 2012\Projects\EmptyDllTest\Debug\EmptyDllTest.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
I can reproduce the log you have only with a totally empty solution. Any chances that for some reason you have not added the source files to the project or they are excluded?

Related

C++ project gets rebuilt due to missing lnk{...}.tmp file in Visual Studio 2022

I have a project in my solution which gets built (consequently all the dependent projects as well) on every run due to the following file missing. I changed the build output verbosity to Diagnostics and got the following line at the top of the build of the said project:
Build started...
1>------ Up-To-Date check: Project: project_name.vcxproj, Configuration: Release x64 ------
1>Project is not up-to-date: build output 'c:\path\appdata\local\temp\lnk{24e28c62-71a7-43ad-81e2-9b34157645b4}.tmp' is missing
1>------ Build started: Project: project_name, Configuration: Release x64 ------
This number (24e28c62-71a7-43ad-81e2-9b34157645b4) changes on every build.
The solutions that I have tried which didn't work:
Deleted the .suo file.
Deleted temp folder, caches and settings.
Reinstalled the VS 2022.
The rebuild happens when I click the build solution regardless of any changes or lack there of in the code.
Edit:
The linker /VERBOSE output on building the said project:
Build started...
1>------ Build started: Project: project_name, Configuration: Release x64 ------
1>Invoking cvtres.exe:
1> /machine:amd64
1> /verbose
1> /out:"C:\Users\path\AppData\Local\Temp\lnk{01385313-5798-4F09-8223-983424FE6954}.tmp"
1> /readonly
1> "C:\Dev\dev\ws2\build\Release_x64\i\project_name\name-of-dll.res"
1>Microsoft (R) Windows Resource To Object Converter Version 14.30.30711.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>adding resource. type:VERSION, name:1, language:0x0407, flags:0x30, size:576
You seem to be building a DLL. So this doesn't apply to you.
But for others that get this when building a static library, hang on...
Here's a possible cause for rebuilds:
Your static library project might contain a resource (*.RC) file.
It's quite odd for a static library to contain a RC file because it could clash with other projects in your solution that consume the static library.
Deleting the .rc and resource.h files can solve the issue (at least it did for me).
The other (top) reason is that your project file points to header files that you have deleted. Since the compiler is not invoked for header files, you won't see errors when building so this is easy to miss!
My specific case was the one described by E. van Putten's answer, where Lib screws up when given a .res file as input. More precisely, it ends up writing the path of a temporary file into the .tlog file that is used for its subsequent up-to-date checks (at which point said file is long gone).
Until this is fixed, I've written a crude MSBuild target that is sequenced right after Lib and filters out nonexistent paths from the generated .tlog file.
<!--
This removes the broken temporary file paths that Lib.exe
puts in tlog files when it processes a .rc file.
See https://stackoverflow.com/q/74536502/3233393.
-->
<Target
Name="BugfixTempFilesInLibTlogs"
AfterTargets="Lib"
Condition="Exists('$(TLogLocation)Lib-link-cvtres.write.1.tlog')"
>
<ReadLinesFromFile
File="$(TLogLocation)Lib-link-cvtres.write.1.tlog"
>
<Output TaskParameter="Lines" ItemName="_LibWriteTlogLines" />
</ReadLinesFromFile>
<!--
Insane item juggling because MSBuild blows up as soon as one mentions `%(FullPath)`
for something that is not actually a path, such as the first line
from the .tlog file (which is of the form `^<file>|</file>|...`)
-->
<ItemGroup>
<_LibWriteTlogLinesToRemove Include="#(_LibWriteTlogLines)" />
<_LibWriteTlogLinesToRemove
Remove="#(_LibWriteTlogLinesToRemove)"
Condition="$([System.String]::new('%(Identity)').StartsWith('^'))"
/>
<_LibWriteTlogLinesToRemove Remove="#(_LibWriteTlogLinesToRemove->Exists())" />
<_LibWriteTlogLines Remove="#(_LibWriteTlogLinesToRemove)" />
</ItemGroup>
<WriteLinesToFile
Condition="'#(_LibWriteTlogLinesToRemove)' != ''"
File="$(TLogLocation)Lib-link-cvtres.write.1.tlog"
Lines="#(_LibWriteTlogLines)"
Overwrite="true"
/>
<ItemGroup>
<_LibWriteTlogLines Remove="#(_LibWriteTlogLines)" />
<_LibWriteTlogLinesToRemove Remove="#(_LibWriteTlogLinesToRemove)" />
</ItemGroup>
</Target>
The .tlog file's name seems to change depending on the input to Lib, so make sure that it matches your case.

Can not open include file; no such file or dir

I created new solution and new project (further A), added another external project (further B) Right click -> add existing project. Now, I have two projects (A & B) in my solution. I added also additional dirs to project A in order to it can see headers of project B. Then I added a few imports in file or project A from project B.
Then if I make right click on project B -> Rebuild it is built without any errors, then if I make right click on project B -> Rebuild I got an error that says :
1>------ Build started: Project: _DecoderEngine, Configuration: Release x64 ------
1>TetStreamDecoder.cpp
1>D:\land\co_main\_Infrastructure\Tier1.0\_FileCodec\_Decoder\_IDecoderCallback.h(3): fatal error C1083: Cannot open include file: '_Shared/_FileTypes.h': No such file or directory
1>Done building project "_DecoderEngine.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
What is weird that a file where I got an error it is a file from project B, it means if I make right click on project B -> Rebuild it is ok, but if I try rebuild project A that has import from B I got and error in files from project B...
What am I doing wrong? I feel like I miss something in configuration, maybe should I add something to Liker or something else?
EDIT
tree looks like this
FileCodec
|
-_DecoderEngine (project A)
|
-_Decoder (project B)
|
-_Shared
FYI - project A use project B and project B use Shared
Then, dependencies I have added to C\C++ -> Additional dirs to project A are :
../_Decoder
../_Shared
Looks ok, because Decoder engine reside on the same level in tree as dependency, so we need to go one level up and here you are.

Could not load file or assembly 'Moq,4.2.1502.911, or one of its dependencies

I have Moq nuget package installed from Manage Nuget Packages for my project. Project builds successfully but when i run the test case, it throws following error
System.IO.FileLoadException: Could not load file or assembly 'Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies
I checked project references and Moq.dll is there.
Also i noticed this on output window for test run
------ Discover test started ------
Unable to load the test container 'C:\dev\tfs\Main\GUI\Gui.Client\Bin\Debug\Gui.Client.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
========== Discover test finished: 20 found (0:00:03.4941998) ==========
------ Run test started ------
Warning: conflict during test run deployment: deployment item 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\Moq.dll' directly or indirectly referenced by the test container 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\gui.client.state.tests.dll' cannot be deployed to 'Moq.dll' because otherwise the file 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\Moq.dll' would overwrite deployment item '..\ThirdPartyLibraries\NuGetPackages\Moq.4.2.1402.2112\lib\net40\Moq.dll' specified by the test settings.
Warning: Test Run deployment issue: The assembly or module 'NMath' directly or indirectly referenced by the test container 'c:\dev\tfs\main\gui\test\gui.client.state.tests\bin\debug\gui.client.state.tests.dll' was not found.
========== Run test finished: 1 run (0:00:23.2373118) ==========
Had the same problem.
Updated the Moq nugets for all projects to they all use the same Moq library and it worked fine for me.
right click on your Moq reference and make sure that you are using the same version everywhere. if not update the using nuget package manager
For me it was that I had "Enable Native Code Debugging" selected as well as "Suppress Jit Compilation". Deselected these, clean and build, and the problem was no longer there.

cant compile secured version of gsoap

i have downloaded gSOAP 2.8.17r stable (update) (20.7 MB)
in /bin/ there are 2 exe wsdl2h.exe and soapcpp2.exe but they
work only with non secure website,now for secured wsdl2h.exe there is a source code in gsoap/VisualStudio2005/... which we have to compile. While compiling i am getting errors
i have already installed minGW,bison,flex,m4,perl,....
also created build custom tools for .l and .y files in the project soapcpp2
as given in readme file.
-------Read me ---------
Flex and Bison for Windows
==========================
Visual Studio 2005 Solution files for soapcpp2 and wsdl2h are included.
If not already installed, install the Platform SDK (R2) for `winsock2.h`.
To build `soapcpp2.exe`, first install Bison and Flex (in the default dirs):
<http://gnuwin32.sourceforge.net/packages/bison.htm>
<http://gnuwin32.sourceforge.net/packages/flex.htm>
then add the FlexBison.rules as explained here:
<http://msdn2.microsoft.com/en-us/library/aa730877(VS.80).aspx>
These custom-build rules are used to build the scanner and parser for
`soapcpp2.exe`.
To build `wsdl2h.exe`, you first need to build `soapcpp2.exe` and install it in
Program Files or copy it to the `wsdl` directory. This is needed to execute the
custom-build step on `wsdl.h` to generate `wsdlStub.h`, `wsdlH.h`, and
`wsdlC.cpp`.
Build Rules for `soapcpp2.exe` VS 2008 and 2010
===============================================
To build `soapcpp2.exe` you need to install Flex and Bison. To do so, you need
to create custom build rules to compile `.l` and `.y` files with Flex and
Bison.
Please see:
<http://msdn.microsoft.com/en-us/library/aa730877(VS.80).aspx#vccustombr_topic3>
In VS2008, there is UI available to help you create the custom build rule.
Make sure you have `flex.exe`, `bison.exe`, and `m4.exe` on the system search
path.
- Right click on the `.l` file and select properties
- Configuration -> All Configurations
- General -> Item Typ e-> Custom Build Tool
- Apply
- Custom Build Tool -> General -> Command Line -> `flex -olexer.c lexer.l`
- Custom Build Tool -> General -> Outputs -> `lexer.c`
- Custom Build Tool -> General -> Additional Dependencies -> `parser.y parser.c`
- Apply
- Select the `.y` file in the solution explorer
- Configuration -> All Configurations
- General -> Item Type -> Custom Build Tool
- Apply
- Custom Build Tool -> General -> Command Line -> `bison -oparser.c parser.y`
- Custom Build Tool -> General -> Outputs -> `parser.c parser.h`
In VS2010, there may not be a UI available to create the custom build rules.
To add or modify build rules in VS2010 you need to edit:
`%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations`
and/or
`%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations`
----------- Error -------------
1>------ Build started: Project: soapcpp2, Configuration: Debug Win32 ------
1>Performing Custom Build Step
1>bison: cannot open file `parser.y': No such file or directory
1>Project : error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
1>Build log was saved at "file://c:\gs\gsoap-2.8\gsoap\VisualStudio2005\soapcpp2\soapcpp2\Debug\BuildLog.htm"
1>soapcpp2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
To build soapcpp2.exe you need to install Flex and Bison. To do so, you need
to create custom build rules to compile .l and .y files with Flex and
Bison.Please see:http://msdn.microsoft.com/en-us/library/aa730877(VS.80).aspx#vccustombr_topic3.
You can download Win flex-bison from sourceforge, when you compile soapcpp2 with VS you should setup custom build rules,please see https://sourceforge.net/p/winflexbison/wiki/Visual%20Studio%20custom%20build%20rules/
Good Luck!
I suppose that parser.y and lexer.l are just wrong names for soapcpp2_lex.l and soapcpp2_yacc.y files we have in soapcpp2 project.
So just correct "Command Line" for both files:
for '.y' file: bison -oparser.c $(InputFileName)
for '.l' file: flex -olexer.c $(InputFileName)

Compile Combination of qtwinmigrate + qtpropertybrowser Under VC++ 2008

I need to display a property browser under a MFC app.
I try to combine and compile the solution for the two
http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Windows/qtwinmigrate/
http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Widgets/qtpropertybrowser/
I am using VC2009, QT 2009.04 with Visual Studio Add-On 1.1.1
Take note, under my machine, there are no problem for me to compile them successfully separately.
I copy, and add all exsiting CPP and HEADER files found in
qtpropertybrowser-2.5-opensource\src
into
qtwinmigrate-2.8-opensource\examples\qtdll
Here is how my new project looks like in the screen shoot (qtwinmigrate - windows at right most)
(source: googlepages.com)
The qtpropertybrowser, is the project which I am able to compile with no problem :
1>------ Rebuild All started: Project: simple, Configuration: Release Win32 ------
1>Deleting intermediate and output files for project 'simple', configuration 'Release|Win32'
1>Moc'ing qtpropertybrowserutils_p.h...
1>RCC ..\..\src\qtpropertybrowser.qrc
1>MOC ..\..\src\qtvariantproperty.h
1>MOC ..\..\src\qttreepropertybrowser.h
1>MOC ..\..\src\qtpropertymanager.h
1>MOC ..\..\src\qtpropertybrowser.h
1>MOC ..\..\src\qtgroupboxpropertybrowser.h
1>MOC ..\..\src\qteditorfactory.h
1>MOC ..\..\src\qtbuttonpropertybrowser.h
1>Compiling...
.
.
.
1>Compiling...
1>moc_qtpropertybrowserutils_p.cpp
1>Linking...
1>Embedding manifest...
However, when come to build modified version of qtwinmigrate (original version of qtwinmigrate was able to compiled with no problem)
1>------ Rebuild All started: Project: qtdialog, Configuration: Release Win32 ------
1>Deleting intermediate and output files for project 'qtdialog', configuration 'Release|Win32'
1>Moc'ing qtpropertybrowserutils_p.h...
1>Moc'ing qteditorfactory.h...
1>Moc'ing qtvariantproperty.h...
1>Moc'ing qttreepropertybrowser.h...
1>Moc'ing qtpropertymanager.h...
1>Moc'ing qtpropertybrowser.h...
1>Moc'ing qtgroupboxpropertybrowser.h...
1>Moc'ing qtbuttonpropertybrowser.h...
1>Moc'ing qwinwidget.h...
1>Moc'ing qwinhost.h...
1>Compiling...
.
.
.
1>Compiling...
1>moc_qtpropertybrowserutils_p.cpp
1>moc_qteditorfactory.cpp
1>.\Release\moc_qteditorfactory.cpp(74) : error C2027: use of undefined type 'QtSpinBoxFactoryPrivate'
1> c:\documents and settings\yan-cheng.cheok\my documents\downloads\qtwinmigrate-2.8-opensource\qtwinmigrate-2.8-opensource\examples\qtdll\release\../../../lib/qtpropertybrowser-2.5-opensource/src/qteditorfactory.h(97) : see declaration of 'QtSpinBoxFactoryPrivate'
1>.\Release\moc_qteditorfactory.cpp(74) : error C2227: left of '->slotPropertyChanged' must point to class/struct/union/generic type
My questions is
Why qtpropertybrowser just perform "Moc'ing" in 1 file, but qtwinmigrate perform "Moc'ing" in so many files?
Why qtpropertybrowser just compile "moc_qtpropertybrowserutils_p.cpp", but qtwinmigrate try to compile so many "moc_....cpp"?
It looks like your two vcproj files don't have the same "moc" properties... It can leads to strange behaviors with the classes that uses the moc...
How did you generate the vcproj file in the second project ?
Did you build both vcproj from the PRO files or just by adding the existing cpp/h files directly in VS ?
If you build the first example from the example's PRO file then just copied the cpp files in another vcproj by adding them through VS, then something probably went wrong with moc properties...
In your vcproj files, try and look for "moc_" and look for differences between the two files... I think it will give you a further step in the process of finding the source of your problem...
I hope it helps a bit...
1) Under Visual Studio 2008, go to Qt -> Open Qt Project File (.pro), open
qtpropertybrowser.pro
2) Go to "simple" Properties, under Build Events -> Pre-Build Event, enter the
following commands :
moc ..\..\src\qttreepropertybrowser.cpp > ..\..\src\qttreepropertybrowser.moc
moc ..\..\src\qtpropertymanager.cpp > ..\..\src\qtpropertymanager.moc
moc ..\..\src\qteditorfactory.cpp > ..\..\src\qteditorfactory.moc
3) Under C/C++ -> Additional Include Directories, enter the following path :
..\..\lib\qtwinmigrate\src
4) Under General -> Configuration Type, change to Dynamic Library (.dll)
5) Under Linker -> General -> Output File, change to \qtdialog.dll
6) Exclude original main.cpp from simple project. Add in main.cpp from
..\..\lib\qtwinmigrate\examples\qtdll
7) Add in all 3 cpp files and 3 header files from
..\..\lib\qtwinmigrate\src
8) Build all. qtdialog.dll will be generated.
9) Open up \lib\qtwinmigrate\examples\mfc\step1. Build all.
10) Move qtdialog.dll same directory as step1 generated exe. Run the application.