Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build and add functions to dll #50

Merged
merged 13 commits into from
Nov 30, 2023
Merged

fix build and add functions to dll #50

merged 13 commits into from
Nov 30, 2023

Conversation

Simplxss
Copy link
Collaborator

No description provided.

@Simplxss Simplxss marked this pull request as ready for review November 29, 2023 13:33
Copy link
Owner

@ihedvall ihedvall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hint: There is a std::string::data() function added so you can write something like:

std::string s(size);
MdfTagGetName(eTag, s.data());

instead

@Simplxss
Copy link
Collaborator Author

Hint: There is a std::string::data() function added so you can write something like:

std::string s(size);
MdfTagGetName(eTag, s.data());

instead

It doesn't work. std::string is not std::vector.

The following code works sometimes, but sometimes it doesn't,

    std::string str;
    str.reserve(MdfAttachmentGetFileType(attachment, nullptr) + 1);
    str.resize(MdfAttachmentGetFileType(attachment, str.data()));
    return str;

@ihedvall
Copy link
Owner

std::string s(size, '\0'); ?

message(STATUS "CLR compile")
add_library(mdflibrary SHARED
src/MdfExport.cpp src/MdfExport.h
# C++ files
src/MdfExport.cpp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the CMake manual, you should add library as a MODULE. If so, you dont't need the Export.cpp file. The -NET have all export function. Well worth a try at least

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot. src/MdfExport.cpp contains functions that need to be exported. If change SHARED to MODULE, cmake would not export symbols to dll.
As the CMake manual said.
"For example, a Windows resource DLL or a managed C++/CLI DLL that exports no unmanaged symbols would need to be a MODULE library."

Copy link
Collaborator Author

@Simplxss Simplxss Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to change SHARED to MODULE, and cmake complains that Target "mdflibrary" of type MODULE_LIBRARY may not be linked into another target. One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to executables with the ENABLE_EXPORTS property set. when run target_link_libraries(mdflibraryexample PRIVATE mdflibrary).

Copy link
Owner

@ihedvall ihedvall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor check if the SHARED ->MODULE is a simpler solution

@Simplxss Simplxss merged commit 7978bd8 into ihedvall:main Nov 30, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants