|
Boost-Build : |
Subject: Re: [Boost-build] MSVC lib project only creates .dll but not .lib
From: Michael Jackson (mike.jackson_at_[hidden])
Date: 2008-12-11 08:17:20
If this is cross platform code then you are going to need a few things
to your code.
First add a header file to your project called MyProjectDllExport.h.
In that file do something like:
// Contents of DLLDefines.h
#ifndef _MyCommon_DLLDEFINES_H_
#define _MyCommon_DLLDEFINES_H_
/* Cmake will define MyLibrary_EXPORTS on Windows when it
configures to build a shared library. If you are going to use
another build system on windows or create the visual studio
projects by hand you need to define MyLibrary_EXPORTS when
building a DLL on windows.
*/
// We are using the Visual Studio Compiler and building Shared libraries
#if defined (_WIN32)
#if defined(MyCommon_EXPORTS)
#define MYLIB_EXPORT __declspec(dllexport)
#else
#define MYLIB_EXPORT __declspec(dllimport)
#endif /* MyCommon_EXPORTS */
#else /* defined (_WIN32) */
#define MYLIB_EXPORT
#endif
#endif /* _MyCommon_DLLDEFINES_H_ */
In your jam file for the Common Library being compiled define
MyCommon_EXPORTS.
For the MyLibrary compilation make sure MyCommon_EXPORTS is NOT defined.
Repeat for the MyLibrary to MyGui compilation.
So for classes in MyCommon define them like this:
class MyCommon_EXPORTS MyCommonClass { };
static functions can be declared like this:
class MyStaticFunctionClass {
public:
static MYLIB_EXPORT void MyExportedFunction(int i);
};
**This was take from the following web site: http://www.cmake.org/Wiki/BuildingWinDLL
which while from a CMake site is applicable to _any_ cross platform
project.
*** This is _not_ an endorsement of CMake or even a suggestion to use
CMake. Just a working example to use for your own bjam project.
_________________________________________________________
Mike Jackson mike.jackson_at_[hidden]
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
On Dec 11, 2008, at 7:12 AM, Christoph Mayer wrote:
> Hi,
>
> I have a boost.build project using the msvc toolset (VC8.0) under
> Windows XP. The project contains two lib and one exe project.
>
> The main jamfile looks as follows and lies in ./ :
>
> ----------<jamfile-begin>----------
> project MyProject ... ;
> use-project /MyProject/MyCommon/ : MyCommon;
> use-project /MyProject/MyLibrary/ : MyLibrary;
> use-project /MyProject/MyGui/ : MyGui;
> build-project MyGui;
> ----------<jamfile-end>----------
>
> The other tree jamfiles for the two lib and one exe projects look as
> follows:
>
> lies in ./MyCommon/
> ----------<jamfile-begin>----------
> lib MyCommon: ...
> ----------<jamfile-end>----------
>
>
> lies in ./MyLibrary/
> ----------<jamfile-begin>----------
> lib MyLibrary: ../MyCommon//MyCommon
> ----------<jamfile-end>----------
>
>
> lies in ./MyGui/
> ----------<jamfile-begin>----------
> exe MyGui: ../MyCommon//MyCommon
> ../MyLibrary//MyLibrary
> ----------<jamfile-end>----------
>
> So, all in all MyLibrary depends on MyCommon and MyGui depends on
> both MyCommon and MyLibrary.
>
> When building the project, boost.build compiles MyCommon and creates
> a dll successfully. Furthermore, it creates a dll for MyLibrary.
> Then boost.build tries to link MyCommon into MyLibrary and fils, as
> there is no .lib file created for MyCommon.
>
> The error is as follows:
> msvc.link.dll MyCommon\bin\msvc-8.0\debug\threading-multi\MyCommon.dll
> msvc.link.dll MyLibrary\bin\msvc-8.0\debug\threading-multi
> \MyLibrary.dll
> LINK : fatal error LNK1181: cannot open input file 'MyCommon\bin
> \msvc-8.0\debug\threading-multi\MyCommon.lib'
>
>
> Am I doing somethings wrong with the project dependencies or why are
> no .lib files created?
>
> Thanks,
> Chris
> --
> Dipl.-Inform. Christoph P. Mayer
> Institute of Telematics, University of Karlsruhe (TH)
> Zirkel 2, 76128 Karlsruhe, Germany
> Phone: +49 721 608 6415, Email: mayer_at_[hidden]
> Web: http://www.tm.uka.de/~mayer/
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk