bugGNU source-highlight - Bugs: bug #57744, Build Windows DLL using MinGW-w64


bug #57744: Build Windows DLL using MinGW-w64

Submitter:  None
Submitted:  Tue 04 Feb 2020 11:52:49 PM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Tue 04 Feb 2020 11:52:49 PM UTC, original submission:  


I was compiling source-highlight for native Windows using MinGW-w64 and noticed that the DLL I was able to build did not export the right symbols.
The reason is that no __declspec(dllexport) / __declspec(dllimport) attributes are specified anywhere in the header files.
Are there still plans to add this?

Below is a dirty attempt to add these attributes to classes and some functions, but I'm pretty sure this is not really correct.
It does however produce a DLL with more relevant export symbols (though probably not all of them).

Are there plans to properly support Windows?


# fix building DLL
for F in $(find lib/srchilite -name '*.h' -or -name '*.hpp'); do
 mv $F $F.bak &&
 echo "#include \"dllexp.h\"" > $F &&
 sed -e "s/^class /&DLL_EXPORT_SRCHIGHLITE /; s/^.* operator/DLL_EXPORT_SRCHIGHLITE &/" $F.bak >> $F
cat > lib/srchilite/dllexp.h << EOF
# if defined(_WIN32) && defined(BUILD_SRCHIGHLITE_DLL)
#  define DLL_EXPORT_SRCHIGHLITE __declspec(dllexport)
# elif defined(_WIN32) && !defined(STATIC) && !defined(BUILD_SRCHIGHLITE_STATIC) && !defined(BUILD_SRCHIGHLITE)
#  define DLL_EXPORT_SRCHIGHLITE __declspec(dllimport)
# else
# endif
# fix static variable in lib/srchilite/verbosity.h
patch -ulbf lib/srchilite/verbosity.h << EOF
@@ -22,4 +22,4 @@
+extern DLL_EXPORT_SRCHIGHLITE bool verbosity;
-    static bool verbosity;
# fix static variable in lib/srchilite/verbosity.cpp
patch -ulbf lib/srchilite/verbosity.cpp << EOF
@@ -17 +17 @@
-bool Verbosity::verbosity = false;
+DLL_EXPORT_SRCHIGHLITE bool verbosity = false;
# fix exports in lib/srchilite/fileutil.h
patch -ulbf lib/srchilite/fileutil.h << EOF
@@ -21,3 +21,3 @@

-extern std::string start_path;
+extern DLL_EXPORT_SRCHIGHLITE std::string start_path;

@@ -30,3 +30,3 @@
-string readFile(const string &fileName) throw (IOException);
+DLL_EXPORT_SRCHIGHLITE string readFile(const string &fileName) throw (IOException);

@@ -42,3 +42,3 @@
-string createOutputFileName(const string &inputFileName,
+DLL_EXPORT_SRCHIGHLITE string createOutputFileName(const string &inputFileName,
         const string &outputDir, const string &ext);
@@ -49,3 +49,3 @@
-unsigned int get_line_count(istream &input);
+DLL_EXPORT_SRCHIGHLITE unsigned int get_line_count(istream &input);

@@ -55,16 +55,16 @@
-string get_file_extension(const string &filename);
+DLL_EXPORT_SRCHIGHLITE string get_file_extension(const string &filename);

-FILE * open_file_stream(const string &input_file_name);
-istream * open_file_istream(const string &filename);
-istream * open_file_istream_or_error(const string &filename);
-istream * open_data_file_istream(const string &path, const string &filename,
+DLL_EXPORT_SRCHIGHLITE FILE * open_file_stream(const string &input_file_name);
+DLL_EXPORT_SRCHIGHLITE istream * open_file_istream(const string &filename);
+DLL_EXPORT_SRCHIGHLITE istream * open_file_istream_or_error(const string &filename);
+DLL_EXPORT_SRCHIGHLITE istream * open_data_file_istream(const string &path, const string &filename,
         const string &start = start_path);
-FILE * open_data_file_stream(const string &path, const string &filename,
+DLL_EXPORT_SRCHIGHLITE FILE * open_data_file_stream(const string &path, const string &filename,
         const string &start = start_path);
-bool read_line(istream *in, string &line);
-string get_file_path(const string &s);
-bool contains_path(const string &);
-string strip_file_path(const string &);
-string get_input_file_name(const string &file_name);
+DLL_EXPORT_SRCHIGHLITE bool read_line(istream *in, string &line);
+DLL_EXPORT_SRCHIGHLITE string get_file_path(const string &s);
+DLL_EXPORT_SRCHIGHLITE bool contains_path(const string &);
+DLL_EXPORT_SRCHIGHLITE string strip_file_path(const string &);
+DLL_EXPORT_SRCHIGHLITE string get_input_file_name(const string &file_name);

# fix building DLL
sed -i.bak -e "s/\$(CXX) /&-DBUILD_SRCHIGHLITE_DLL /" lib/srchilite/Makefile.in



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


CC list is empty


There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.


No changes have been made to this item

Back to the top

Powered by Savane 3.13-ee12.
Corresponding source code