I have never had problems with GTK+ on Windows. That said, I think you are working both ends against the middle here. You must either build against
glib or not. You can't do both.
If your public interface uses
glib entities, then your component's user
must have
glib installed to use your component. So in order to satisfy the requirement, you must remove
glib from your component's public interface. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#ifndef TextFileConverter_h
#define TextFileConverter_h
#include <iostream>
#include <string>
class CTextFileConverter
{
public:
typedef enum
{
IO_STATUS_ERROR,
IO_STATUS_NORMAL,
IO_STATUS_EOF,
IO_STATUS_AGAIN
} IOStatus;
// Methods to get an open file channel
bool open_file( const char* filename );
bool attach_fd( int fd );
...
// Methods to undo them
void close_file();
void detach_fd();
...
IOStatus read_line( std::string& destination );
int convert_to_utf8( const std::string& filePath, std::string& destinationPath ) const;
int replaceEnd( const std::string& filePath, std::string& destinationPath, const std::string& replaced, const std::string& replacer ) const;
int unix_to_win( const std::string& filePath, std::string& destinationPath ) const;
int win_to_unix( const std::string& filePath, std::string& destinationPath ) const;
private:
void* data;
};
#endif
|
I've made a few modifications.
1.
IOStatus is basically a
GIOStatus. But the people using your library don't need to know that. Nor do they need to install GTK+ headers.
2. The
GIOChannel object is hidden away. Unless there is also other state data you want to keep, you can just cast the
data pointer to address a
GIOChannel. Keep in mind that your object is now responsible with
newing and
deleteing the
GIOChannel object itself. In order to do this, I also introduced methods to initialize and finalize the file converter. It might be worth turning those methods into constructor(s) and destructor(s).
Of course, this is only an example. Make the initializers/constructors the way you need them --just keep the
GIOChannel you are using out of view.
3. Use standard
string objects instead of
GStrings and
char*s. This gives the user a lot more flexibility: for example, he can call
convert_to_utf8 with a char*, a const char*, a string, a const string, a temporary, etc. (The destination path must always be a string though...)
4. Make sure that your object is "const correct". Methods which don't modify your object are properly marked as
const, as are argument references which don't modify their source data. This makes your object more usable.
Now you can compile your DLL using
glib, and distribute just the GTK DLL(s) and your own DLL with the above header.
Hope this helps.