Need a example to use dll in vs

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Need a example to use dll in vs

Chaos Zhang
This post was updated on .
Hi all,

I faced a problem when i migrated a project from Linux to windows for the visual stdio seem can not use dll directly. I look through a number of materials  and known i seem should use IMPORTED in add_library(...), but i can not find a practical example about how to use it. Could you please give me one or some? BTW the dll lib seem could be used in Mingw makefile on windows.

Thanks,
Chao Zhang
Reply | Threaded
Open this post in threaded view
|

Re: Need a example to use dll in vs

Scott Bloom
When I am building DLLs I tend to use an "install step" as part of my cmake process.  Then I make sure the builds' install area is in the path of the application.

The issue may be your EXE cant find the DLL in its path.

Scott

-----Original Message-----
From: CMake [mailto:[hidden email]] On Behalf Of Chaos Zhang
Sent: Sunday, April 24, 2016 8:14 PM
To: [hidden email]
Subject: [CMake] Need a example to use dll in vs

Hi all,

I faced a problem when i migrate a project from Linux to windows for the visual stdio seem can not use dll directly. I look through a number of material  and known i seem should use IMPORTED in add_library(...), but i can not find a practical example about how to use it. Could you please give me one or some? BTW the dll lib seem could be used in Mingw makefile on windows.

Thanks,
Chao Zhang



--
View this message in context: http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
Sent from the CMake mailing list archive at Nabble.com.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Need a example to use dll in vs

Chaos Zhang
Thanks for your reply Mr Scott, but my project worked well on Linux and i am sure the path is right. This question has been asked long before, as below:
On Sat, Jul 24, 2010 at 11:00 PM, John Drescher <drescherjm at gmail.com> wrote:
>>> I know that target_link_libraries can be used to link a .lib ,
>>>
>>> but how to link a .dll into the project?
>>>
>>>
>> You do not link against a .dll in windows ever.
>>
> When you create a .dll there is also a small import lib associated
> with the dll. You link with that and when the application starts it
> searches the path for each dll it needs.
>
> John

And the error was not dll lib was not found but .lib(static lib) was not found. As i knew so far, i think this error is related to windows platform.

Scott Aron Bloom-2 wrote
When I am building DLLs I tend to use an "install step" as part of my cmake process.  Then I make sure the builds' install area is in the path of the application.

The issue may be your EXE cant find the DLL in its path.

Scott

-----Original Message-----
From: CMake [mailto:[hidden email]] On Behalf Of Chaos Zhang
Sent: Sunday, April 24, 2016 8:14 PM
To: [hidden email]
Subject: [CMake] Need a example to use dll in vs

Hi all,

I faced a problem when i migrate a project from Linux to windows for the visual stdio seem can not use dll directly. I look through a number of material  and known i seem should use IMPORTED in add_library(...), but i can not find a practical example about how to use it. Could you please give me one or some? BTW the dll lib seem could be used in Mingw makefile on windows.

Thanks,
Chao Zhang



--
View this message in context: http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
Sent from the CMake mailing list archive at Nabble.com.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Need a example to use dll in vs

Jakob van Bethlehem
In reply to this post by Chaos Zhang
Hej,

You really should provide more detailed information about your project structure, and what is going wrong. There are some subtle differences between Linux/Windows, but not at the level you're referring to. Certainly the IMPORTED property has nothing to do with a platform distinction. IMPORTED libraries work exactly the same on Windows/Linux. 

There is a very big difference between Linux/Windows though in the sense that on Windows you need to explicitly export symbols you want to be available on the interface of the dll. My first guess from your very limited info is that something is wrong in that area (and if that's the case, you can easily resolve this using the GenerateExportHeader module). 

But back to my original comment: provide more details on what you are trying to do, and what is failing.

Sincerely,
Jakob van Bethlehem

On Mon, Apr 25, 2016 at 5:13 AM, Chaos Zhang <[hidden email]> wrote:
Hi all,

I faced a problem when i migrate a project from Linux to windows for the
visual stdio seem can not use dll directly. I look through a number of
material  and known i seem should use IMPORTED in add_library(...), but i
can not find a practical example about how to use it. Could you please give
me one or some? BTW the dll lib seem could be used in Mingw makefile on
windows.

Thanks,
Chao Zhang



--
View this message in context: http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
Sent from the CMake mailing list archive at Nabble.com.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Need a example to use dll in vs

Chaos Zhang
This post was updated on .
Thanks for your advice, i have add a new topic named "How to link shared lib on windows (visual studio 2014)", sincerely look forward to your reply. ^_^

My new topic link: http://cmake.3232098.n2.nabble.com/How-to-link-shared-lib-on-windows-visual-studio-2014-td7593346.html

Chao

Jakob van Bethlehem wrote
Hej,

You really should provide more detailed information about your project
structure, and what is going wrong. There are some subtle differences
between Linux/Windows, but not at the level you're referring to. Certainly
the IMPORTED property has nothing to do with a platform distinction.
IMPORTED libraries work exactly the same on Windows/Linux.

There is a very big difference between Linux/Windows though in the sense
that on Windows you need to explicitly export symbols you want to be
available on the interface of the dll. My first guess from your very
limited info is that something is wrong in that area (and if that's the
case, you can easily resolve this using the GenerateExportHeader module).

But back to my original comment: provide more details on what you are
trying to do, and what is failing.

Sincerely,
Jakob van Bethlehem

On Mon, Apr 25, 2016 at 5:13 AM, Chaos Zhang <[hidden email]> wrote:

> Hi all,
>
> I faced a problem when i migrate a project from Linux to windows for the
> visual stdio seem can not use dll directly. I look through a number of
> material  and known i seem should use IMPORTED in add_library(...), but i
> can not find a practical example about how to use it. Could you please give
> me one or some? BTW the dll lib seem could be used in Mingw makefile on
> windows.
>
> Thanks,
> Chao Zhang
>
>
>
> --
> View this message in context:
> http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
> Sent from the CMake mailing list archive at Nabble.com.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake