|
can't get the simple visual c++ example "simplebar" to link |
Posted by JSmith on Oct-19-2024 08:18 |
|
Have spent 4 hours trying to figure out this error:
Build started at 5:04 PM...
1>------ Build started: Project: simplebar, Configuration: Debug x64 ------
1>D:\ChartDirector\CDfiles\ChartDirector\lib64\chartdir70.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x340
1>Done building project "simplebar.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 5:04 PM and took 00.472 seconds ==========
-have tried every permutation of additional paths in the project/properties dialog in visual studio c++ (2022).
-re-downloaded install from website in case the original chardir70.dll was corrupted; no difference.
put copies of the chartdir70.dll and the chartdir70.lib in the main dir, the debug dir, and the x64 directories; no effect.
How do I connect the lib or dll to the simplebar code?
sign me,
stumped??
any help would be great. thanks |
Re: can't get the simple visual c++ example "simplebar" to link |
Posted by Peter Kwan on Oct-19-2024 13:36 |
|
Hi JSmith,
Please link with the import library "chartdir70.lib", not the "chartdir70.dll".
The "chartdir70.dll" is a dynamic library. A dynamic library means it is used when you run the program, not when you compile or link the program. When you compile the program, the import library "chartdir70.lib" should be used. This is the same for all other DLLs.
In general, in C++, you need 3 things:
(a) For compilation, you need the header files. It means you need to set up the include directories.
(b) For linking, you need the import library ("chartdir70.lib")
(c) To run the program, you need the DLL. To ensure the executable can find the DLL, the DLL needs to be in the same directory as your executable or in any directory in your system DLL search path.
For (c), in our sample project, we add a post built event to automatically copy the DLL to the Visual Studio output directory so that the project can be executed easily. If you do not bother to set up a post build event, you can manually copy the DLL to the output directory that contains the executable.
I have attached the screenshots from the sample project for your reference. Note that you may need to change the path to fit your own directory structure.
Best Regards
Peter Kwan
|
Re: can't get the simple visual c++ example "simplebar" to link |
Posted by JSmith on Oct-20-2024 02:32 |
|
Thanks Peter, I got it to work by taking screen shots of another example's properties settings in VS compared to mine. when I corrected to those settings it worked. whew.
thanks for your response. My app is 30k SLOC's in C++ and I am trying to connect to your code to display bar charts of the results it produces. Since I'm a newbie to plotting I appreciate your patience.
thank you,
jeff |
|