Hello list,

Raptor recently gained CMake build support, facilitating Windows builds. However, it is not yet possible to build Raptor and its associated test programs in DLL mode:

--------8<--------
cmd> cmake -G"NMake Makefiles" -DBUILD_SHARED_LIBS=ON \path\to\raptorSource
[CMake configuration output elided]
cmd> nmake
[...]
[ 74%] Building C object src/CMakeFiles/raptor2.dir/parsedate.c.obj
parsedate.c
Linking C shared library raptor2.dll
   Creating library raptor2.lib and object raptor2.exp
   Creating library raptor2.lib and object raptor2.exp
[ 74%] Built target raptor2
Scanning dependencies of target raptor_avltree_test
[ 75%] Building C object 
src/CMakeFiles/raptor_avltree_test.dir/raptor_avltree.c.obj
raptor_avltree.c
Linking C executable raptor_avltree_test.exe
raptor_avltree.c.obj : error LNK2019: unresolved external symbol 
raptor_basename referenced in function main
raptor_avltree_test.exe : fatal error LNK1120: 1 unresolved externals
LINK Pass 1 failed. with 2
NMAKE : fatal error U1077: 'cmake.exe' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: 'nmake.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'nmake.exe' : return code '0x2'
Stop.
-------->8--------

The problem is that numerous Raptor-internal functions are required by the test programs, but these functions are unavailable because they were not declared with the necessary DLL export/import linkage. Adding RAPTOR_API to their declarations in raptor_internal.h and turtle_common.h allows the build to complete.

(RAPTOR_API may be intended specifically to annotate Raptor's public-API functions, however, so possibly another macro is desired here.)

The internal functions leading to "unresolved external symbol" linker errors are the following:

        raptor_basename
        raptor_check_world_internal
        raptor_free_id_set
        raptor_free_turtle_writer
        raptor_free_uri_detail
        raptor_id_set_add
        raptor_log_error_formatted
        raptor_new_id_set
        raptor_new_turtle_writer
        raptor_new_uri_detail
        raptor_parser_get_accept_header_all
        raptor_parser_log_error_varargs
        raptor_stringbuffer_append_turtle_string
        raptor_turtle_writer_decrease_indent
        raptor_turtle_writer_increase_indent
        raptor_turtle_writer_literal
        raptor_turtle_writer_namespace_prefix
        raptor_turtle_writer_newline
        raptor_turtle_writer_qname
        raptor_turtle_writer_quoted_counted_string
        raptor_turtle_writer_raw
        raptor_turtle_writer_raw_counted
        raptor_turtle_writer_reference
        raptor_turtle_writer_set_option
        turtle_qname_to_uri
        turtle_syntax_error


The attached patch adds RAPTOR_API (for now) to the declarations of all of the above, allowing a DLL build to complete successfully.

Questions and comments are welcome.


--Daniel


--
Daniel Richard G. || [email protected] || Software Developer
Teragram Linguistic Technologies (a division of SAS)
http://www.teragram.com/
diff --git a/src/raptor_internal.h b/src/raptor_internal.h
index 5920150..d5f0027 100644
--- a/src/raptor_internal.h
+++ b/src/raptor_internal.h
@@ -676,24 +676,24 @@ unsigned char* raptor_world_internal_generate_id(raptor_world *world, unsigned c
 #ifdef RAPTOR_DEBUG
 void raptor_stats_print(raptor_parser *rdf_parser, FILE *stream);
 #endif
-const char* raptor_basename(const char *name);
+RAPTOR_API const char* raptor_basename(const char *name);
 int raptor_term_print_as_ntriples(const raptor_term *term, FILE* stream);
 
 /* raptor_parse.c */
 raptor_parser_factory* raptor_world_get_parser_factory(raptor_world* world, const char *name);  
 void raptor_delete_parser_factories(void);
-const char* raptor_parser_get_accept_header_all(raptor_world* world);
+RAPTOR_API const char* raptor_parser_get_accept_header_all(raptor_world* world);
 int raptor_parser_set_uri_filter_no_net(void *user_data, raptor_uri* uri);
 void raptor_parser_parse_uri_write_bytes(raptor_www* www, void *userdata, const void *ptr, size_t size, size_t nmemb);
 void raptor_parser_fatal_error(raptor_parser* parser, const char *message, ...) RAPTOR_PRINTF_FORMAT(2, 3);
 void raptor_parser_error(raptor_parser* parser, const char *message, ...) RAPTOR_PRINTF_FORMAT(2, 3);
-void raptor_parser_log_error_varargs(raptor_parser* parser, raptor_log_level level, const char *message, va_list arguments) RAPTOR_PRINTF_FORMAT(3, 0);
+RAPTOR_API void raptor_parser_log_error_varargs(raptor_parser* parser, raptor_log_level level, const char *message, va_list arguments) RAPTOR_PRINTF_FORMAT(3, 0);
 void raptor_parser_warning(raptor_parser* parser, const char *message, ...) RAPTOR_PRINTF_FORMAT(2, 3);
 
 /* logging */
 void raptor_world_internal_set_ignore_errors(raptor_world* world, int flag);
 void raptor_log_error_varargs(raptor_world* world, raptor_log_level level, raptor_locator* locator, const char* message, va_list arguments) RAPTOR_PRINTF_FORMAT(4, 0);
-void raptor_log_error_formatted(raptor_world* world, raptor_log_level level, raptor_locator* locator, const char* message, ...) RAPTOR_PRINTF_FORMAT(4, 5);
+RAPTOR_API void raptor_log_error_formatted(raptor_world* world, raptor_log_level level, raptor_locator* locator, const char* message, ...) RAPTOR_PRINTF_FORMAT(4, 5);
 void raptor_log_error(raptor_world* world, raptor_log_level level, raptor_locator* locator, const char* message);
 
 
@@ -883,8 +883,8 @@ int raptor_init_serializer_atom(raptor_world* world);
 extern const unsigned char * const raptor_atom_namespace_uri;
 
 /* raptor_rfc2396.c */
-raptor_uri_detail* raptor_new_uri_detail(const unsigned char *uri_string);
-void raptor_free_uri_detail(raptor_uri_detail* uri_detail);
+RAPTOR_API raptor_uri_detail* raptor_new_uri_detail(const unsigned char *uri_string);
+RAPTOR_API void raptor_free_uri_detail(raptor_uri_detail* uri_detail);
 unsigned char* raptor_uri_detail_to_string(raptor_uri_detail *ud, size_t* len_p);
 
 /* serializers */
@@ -1015,9 +1015,9 @@ void raptor_www_libfetch_free(raptor_www *www);
 int raptor_www_libfetch_fetch(raptor_www *www);
 
 /* raptor_set.c */
-raptor_id_set* raptor_new_id_set(raptor_world* world);
-void raptor_free_id_set(raptor_id_set* set);
-int raptor_id_set_add(raptor_id_set* set, raptor_uri* base_uri, const unsigned char *item, size_t item_len);
+RAPTOR_API raptor_id_set* raptor_new_id_set(raptor_world* world);
+RAPTOR_API void raptor_free_id_set(raptor_id_set* set);
+RAPTOR_API int raptor_id_set_add(raptor_id_set* set, raptor_uri* base_uri, const unsigned char *item, size_t item_len);
 #if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 1
 void raptor_id_set_stats_print(raptor_id_set* set, FILE *stream);
 #endif
@@ -1210,7 +1210,7 @@ typedef void (*raptor_simple_message_handler)(void *user_data, const char *messa
 
 
 /* turtle_common.c */
-int raptor_stringbuffer_append_turtle_string(raptor_stringbuffer* stringbuffer, const unsigned char *text, size_t len, int delim, raptor_simple_message_handler error_handler, void *error_data);
+RAPTOR_API int raptor_stringbuffer_append_turtle_string(raptor_stringbuffer* stringbuffer, const unsigned char *text, size_t len, int delim, raptor_simple_message_handler error_handler, void *error_data);
 
 
 /* raptor_abbrev.c */
@@ -1272,21 +1272,21 @@ raptor_qname* raptor_new_qname_from_resource(raptor_sequence* namespaces, raptor
 typedef struct raptor_turtle_writer_s raptor_turtle_writer;
 
 /* Turtle Writer Class (raptor_turtle_writer) */
-raptor_turtle_writer* raptor_new_turtle_writer(raptor_world* world, raptor_uri* base_uri, int write_base_uri, raptor_namespace_stack *nstack, raptor_iostream* iostr);
-void raptor_free_turtle_writer(raptor_turtle_writer* turtle_writer);
-void raptor_turtle_writer_raw(raptor_turtle_writer* turtle_writer, const unsigned char *s);
-void raptor_turtle_writer_raw_counted(raptor_turtle_writer* turtle_writer, const unsigned char *s, unsigned int len);
-void raptor_turtle_writer_namespace_prefix(raptor_turtle_writer* turtle_writer, raptor_namespace* ns);
+RAPTOR_API raptor_turtle_writer* raptor_new_turtle_writer(raptor_world* world, raptor_uri* base_uri, int write_base_uri, raptor_namespace_stack *nstack, raptor_iostream* iostr);
+RAPTOR_API void raptor_free_turtle_writer(raptor_turtle_writer* turtle_writer);
+RAPTOR_API void raptor_turtle_writer_raw(raptor_turtle_writer* turtle_writer, const unsigned char *s);
+RAPTOR_API void raptor_turtle_writer_raw_counted(raptor_turtle_writer* turtle_writer, const unsigned char *s, unsigned int len);
+RAPTOR_API void raptor_turtle_writer_namespace_prefix(raptor_turtle_writer* turtle_writer, raptor_namespace* ns);
 void raptor_turtle_writer_base(raptor_turtle_writer* turtle_writer, raptor_uri* base_uri);
-void raptor_turtle_writer_increase_indent(raptor_turtle_writer *turtle_writer);
-void raptor_turtle_writer_decrease_indent(raptor_turtle_writer *turtle_writer);
-void raptor_turtle_writer_newline(raptor_turtle_writer *turtle_writer);
-void raptor_turtle_writer_reference(raptor_turtle_writer* turtle_writer, raptor_uri* uri);
-int raptor_turtle_writer_literal(raptor_turtle_writer* turtle_writer, raptor_namespace_stack *nstack, const unsigned char *s, const unsigned char* lang, raptor_uri* datatype);
-void raptor_turtle_writer_qname(raptor_turtle_writer* turtle_writer, raptor_qname* qname);
-int raptor_turtle_writer_quoted_counted_string(raptor_turtle_writer* turtle_writer, const unsigned char *s, size_t length);
+RAPTOR_API void raptor_turtle_writer_increase_indent(raptor_turtle_writer *turtle_writer);
+RAPTOR_API void raptor_turtle_writer_decrease_indent(raptor_turtle_writer *turtle_writer);
+RAPTOR_API void raptor_turtle_writer_newline(raptor_turtle_writer *turtle_writer);
+RAPTOR_API void raptor_turtle_writer_reference(raptor_turtle_writer* turtle_writer, raptor_uri* uri);
+RAPTOR_API int raptor_turtle_writer_literal(raptor_turtle_writer* turtle_writer, raptor_namespace_stack *nstack, const unsigned char *s, const unsigned char* lang, raptor_uri* datatype);
+RAPTOR_API void raptor_turtle_writer_qname(raptor_turtle_writer* turtle_writer, raptor_qname* qname);
+RAPTOR_API int raptor_turtle_writer_quoted_counted_string(raptor_turtle_writer* turtle_writer, const unsigned char *s, size_t length);
 void raptor_turtle_writer_comment(raptor_turtle_writer* turtle_writer, const unsigned char *s);
-int raptor_turtle_writer_set_option(raptor_turtle_writer *turtle_writer, raptor_option option, int value);
+RAPTOR_API int raptor_turtle_writer_set_option(raptor_turtle_writer *turtle_writer, raptor_option option, int value);
 int raptor_turtle_writer_set_option_string(raptor_turtle_writer *turtle_writer, raptor_option option, const unsigned char *value);
 int raptor_turtle_writer_get_option(raptor_turtle_writer *turtle_writer, raptor_option option);
 const unsigned char *raptor_turtle_writer_get_option_string(raptor_turtle_writer *turtle_writer, raptor_option option);
@@ -1337,7 +1337,7 @@ size_t raptor_format_integer(char* buffer, size_t bufsize, int integer, unsigned
   } while(0)  
     
 
-int raptor_check_world_internal(raptor_world* world, const char* name);
+RAPTOR_API int raptor_check_world_internal(raptor_world* world, const char* name);
 
 
 
diff --git a/src/turtle_common.h b/src/turtle_common.h
index 0592d60..632e143 100644
--- a/src/turtle_common.h
+++ b/src/turtle_common.h
@@ -31,8 +31,8 @@ extern "C" {
 
 
 /* turtle_parser.y */
-int turtle_syntax_error(raptor_parser *rdf_parser, const char *message, ...) RAPTOR_PRINTF_FORMAT(2, 3);
-raptor_uri* turtle_qname_to_uri(raptor_parser *rdf_parser, unsigned char *name, size_t name_len);
+RAPTOR_API int turtle_syntax_error(raptor_parser *rdf_parser, const char *message, ...) RAPTOR_PRINTF_FORMAT(2, 3);
+RAPTOR_API raptor_uri* turtle_qname_to_uri(raptor_parser *rdf_parser, unsigned char *name, size_t name_len);
 
 /* turtle_lexer.l */
 extern void turtle_token_free(raptor_world* world, int token, YYSTYPE *lval);
_______________________________________________
redland-dev mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-dev

Reply via email to