|
I am trying to use VTK library into an MFC project ... I had do everything to can compile my project, (add headers and library files to my project), but when I try to run the program, I get follow error:
The program can't start because vtkRenderingCore-1.6.dll is missing from your computer
but I alreay use vtkRenderingCore-1.6.lib file (and his header), why do I need dll file ?
I had used another library once upon a time(PDFlib), but then I had used just header file, and library file ...
So, the question is, do I need a dll file if I am using library (and header file) inside the project ?
|
|
|
|
|
Compiled libraries come in 2 flavors - static libraries and dynamic libraries.
Static libraries are in the form of a .LIB file and dynamic libraries are in the form of a .DLL file.
A .DLL file can also have an associated .LIB file. But this .LIB file only contains the exported function signatures and the name of the .DLL file.
It does not contain any code.
During runtime, the DLL file will be searched in specific folders as mentioned here - Dynamic-Link Library Search Order[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
I want to know the details of linker,do you have any suggestion?
|
|
|
|
|
Superman allready explained in his answer that in general there are two types of libaries (static and dynamic or also called shared libraries).
Now when using VTK you can choose if you would like to use the static libraries or the dynamic ones. Assuming you did build VTK yourself in the CMake configuration you'll have to set the option BUILD_SHARED_LIBS=OFF.
This way VTK will be build as static libraries.
|
|
|
|
|
Yes, that I already done it ... but still, I am not able to compile an MFC project with VTK, just console applications that had VTK inside ... I am still digging ....
|
|
|
|
|
Do you have problems compiling or linking? Because before you were talking about libraries and they only come into play afer you successfully compiled your pogram and now your telling that you have problems compiling.
|
|
|
|
|
Regor, kindly thank you. I am trying to compile their SampleMFC project, that has following CMakeList.txt:
cmake_minimum_required(VERSION 2.8)
PROJECT(Win32SampleMFC)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})
# This VTK_DIR usage only works in the VTK build tree...
# Make it work in the "make install" tree, too.
#
INCLUDE("${VTK_DIR}/GUISupport/MFC/VTKMFCSettings.cmake")
IF(VTK_MFC_DELAYLOAD_VTK_DLLS)
VTK_MFC_ADD_DELAYLOAD_FLAGS(CMAKE_EXE_LINKER_FLAGS
vtkRendering.dll
vtkIO.dll
vtkFiltering.dll
vtkCommon.dll
)
ENDIF(VTK_MFC_DELAYLOAD_VTK_DLLS)
SET(SRCS
ChildFrm.cpp
MainFrm.cpp
Sample.cpp
Sample.rc
SampleDoc.cpp
SampleView.cpp
StdAfx.cpp
vtkMFCDocument.cpp
vtkMFCRenderView.cpp
vtkMFCView.cpp
res/Sample.rc2
)
ADD_EXECUTABLE(Win32SampleMFC WIN32 ${SRCS})
IF(VTK_MFC_EXTRA_LIBS)
TARGET_LINK_LIBRARIES(Win32SampleMFC ${VTK_MFC_EXTRA_LIBS})
ENDIF(VTK_MFC_EXTRA_LIBS)
TARGET_LINK_LIBRARIES(Win32SampleMFC vtkRendering)
well, in VTK, version 6, I didn't have
<br />
vtkRendering.dll<br />
vtkIO.dll<br />
vtkFiltering.dll<br />
vtkCommon.dll<br />
and I don't know how to adapt CMakeList.txt in order to compile the project ...
and I got linking error:
fatal error LNK1104: cannot open file 'vtkRendering.lib'
Also, I didn't have any vtkRendering.lib , just vtkRenderingCore-6.1.lib
Any help that you give, will be very appreciated !
|
|
|
|
|
Yes in VTK version 6 the naming convention for the libraries was changed. It is now part of the lib name, that is why you have a vtkRenderingCore-6.1.lib instead of vtkRendering.lib. It seems those changes did not make it in the cmake files of the example you're trying to use. Anyway when using cmake you shouldnt care about the concrete names of the libs since this is handled by the cmake configuration. I can show you how I succesfully link VTK 6.1 to one of my projects:
# Try to automatically detect VTK.
find_package(VTK REQUIRED COMPONENTS vtkIOGeometry vtkIOLegacy vtkFiltersCore)
if(VTK_FOUND)
message(STATUS "Found package VTK. Using " ${VTK_USE_FILE})
include(${VTK_USE_FILE})
else(VTK_FOUND)
message(FATAL_ERROR "VTK not found. Please set VTK_DIR.")
endif(VTK_FOUND)
target_link_libraries(myTarget ${VTK_LIBRARIES})
In your place I would start trying to build a basic VTK project (Hello World etc.) at first to see if this works. If you got this you can start to add simple MFC functionality.
I did not use MFC with VTK myself so sadly I cannot share any experience about this combination.
|
|
|
|
|
Ok, thank you, right now I should leave the office, but tomorrow I will write you what I have done ... see you soon.
|
|
|
|
|
Finnaly I make it .. .thank you for all your support ! See you.
|
|
|
|
|
Congratulations! Cmake configuration may be nerve-wrecking (and often are imo ). See you
|
|
|
|
|
hey guys I am new for c++ and I wana to write program in C++, that will generate the Series of this program 1+-3+5+-7+9+-11..... who can help me
|
|
|
|
|
What have you tried so far?
|
|
|
|
|
You can use a for loop that starts a counter from 1 and increments it by 2 each time.
For each alternate path through the loop multiply the counter by -1.
You can check for the alternate path by toggling a bool variable to true and false .
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
I can only point you in the right direction.
#include <iostream>
using namespace std;
int main()
{
int n=43, sum = 0,neg= 1;
for(int i = 1; i <= n; i+=2)
{
sum += (i*neg);
cout <<"i="<<i<< " neg sgn =" << (i*neg)<< " sum ="<< sum << " \n";
neg=-neg;
}
cout<<"\n";
return 0;
}
|
|
|
|
|
#include<iostream.h>
main()
{
int n;
cout<<"Enter the Number:";
cin>>n;
for(int i=1,j=1;j<=n;i+=2,j++)
{
if(i==1)
cout<<i;
else if(j%2==0)
cout<<"+-"<<i;
else
cout<<"+"<<i;
}
}
|
|
|
|
|
I see your C++ compiler is a bit dated.
Veni, vidi, vici.
|
|
|
|
|
At first, let me describe our current architecture:
Our project is based on MFC multiple doc view, and the project contains many submodules. The submodule contains two projects: one is a resource-only prject(dll), and another is a static library project. We extract resources from the dll(generated by resource-only project), then generate a *.cpp file which contains alll the resource data, include the *.cpp into static project. After linking with the static library, the Main Frame must use some helper functions to extract resources from *.cpp when it must use the resource from submodule.
Now I want to find a better architecture to replace the current one, because its complexity of managing resource is sooo high.
Anybody can help me?
I'm not sure these words can make you understand me correctly?
|
|
|
|
|
As I understand it, you're extracting the resources from a DLL, embedding it into a static library and then again extracting it from the static library.
What I don't understand here is, why the double extraction.
Why not extract the resources directly from the DLL by the frame?
Is it because it should be a single EXE without any DLLs?
If you're able to use the EXE along with the DLLs, then the design can be in such a way that the EXE, at runtime, extracts the resources from the resource only DLL and calls into the static library passing it the extracted resource.
If multiple files are the problem, it is even possible to embed the resource only DLL into the EXE itself.
If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
At first, thank your for your reply.
yes, you are right. because it should be a single EXE without any DLLs.
>>it is even possible to embed the resource only DLL into the EXE itself.
could you explain how to do it? If successfully do it, how can submodule access the resource?
>>If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself.
as far as i can see, it's not possible to embed resources into static library directly, could you explain your idea?
|
|
|
|
|
Falconapollo wrote: >>it is even possible to embed the resource only DLL into the EXE itself.
could you explain how to do it? If successfully do it, how can submodule access the resource?
To embed a DLL in the resource, first create a custom type resource -
Right click on the .rc file in the resource view and select Add Resource -> Custom .
Give it any name like DLL.
The newly created resource will open in a binary editor and will be blank.
Now open the DLL file using the binary editor by using File -> Open , select the DLL and choose Open With -> Binary editor .
Select all the contents of the DLL (Ctrl + A), copy and paste it in the newly created resource file and save it.
To access the resource at runtime, do the following -
Use FindResource[^] to locate the resource.
Use SizeofResource[^] to get the size of the resource.
Use LoadResource[^] to get a handle to the resource.
Use LockResource[^] to get a pointer to the memory where the resource is loaded.
Use CopyMemory[^] to copy the resource contents into a buffer.
Now Create a new binary file using CreateFile[^].
Use WriteFile[^] to write the contents of the buffer into the file.
Now you have a resource only DLL file on disk that you can use just like a normal resource only DLL file.
Falconapollo wrote: >>If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself.
as far as i can see, it's not possible to embed resources into static library directly, could you explain your idea?
You can create resources in static libraries in the exact same way as you do in an EXE or DLL project.
However, there are some caveats to it.
Read about it here -
VC++ resources in a static library[^]
LINKING RESOURCES FROM A STATIC LIBRARY[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Thank you for your quick reply.
One more question: what if i modify our resources more frequently? it seems unconvenient to embed resources into static lib or exe, because i can't edit them directly...
|
|
|
|
|
Actually, you can - Using Resources[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
um...you might misunderstood me,i meants it's inconvenicent to edit *.rc file directly, for instance, adding dialog, adding strings, adding icons... it's even more inconvenient to use function: UpdateResource...
|
|
|
|
|
How do i find the position of taskbar in MFC...
|
|
|
|