vurtun / nuklear

A single-header ANSI C gui library
13.69k stars 1.11k forks source link

Overwhelming amount of Compiler Errors (VC2015 C++, standalone header) #159

Closed KenzieMac130 closed 8 years ago

KenzieMac130 commented 8 years ago

Hello, I just recently came across nuklear. I must say after trying many different GUI libraries only to find dissatisfaction with their invasive implementation and bloated unnecessary nonsense, nuklear seems very promising with its relatively lightweight and flexible approach as a library.

However, I can't really seem to get it working in my project as there are 109 errors at the moment coming from the nuklear header file. I'm not sure if I set it up incorrectly, I assume that the libary only requires you to include the header like any other header-only library but I can't seem to find any documentation on setting up the library without using the demo applications as a foundation. I have not yet started building a bridge between nuklear and my programs DX11 rendering framework and input structure, outside of including nuklear.h in an engine header file after defining the following: NK_INCLUDE_FIXED_TYPES NK_INCLUDE_STANDARD_IO NK_INCLUDE_DEFAULT_ALLOCATOR NK_INCLUDE_VERTEX_BUFFER_OUTPUT NK_INCLUDE_FONT_BAKING NK_INCLUDE_DEFAULTFONT (I saw these in the demo, they brought the error count down from over 200 to 109)_

Now Some of the errors I am getting include: 1: linkage specification is incompatible with previous "nk_begin" 23: cannot overload functions distinguished by return type alone and the other 85: more than one instance of overloaded function "XXXXX" has 'C' linkage

I'm sort of at a loss at this one; so any help or clarification on what I did horribly wrong would be greatly appreciated.

vurtun commented 8 years ago

Hey, I am not 100% sure but I compiled and checked nuklear on windows with my Directx11 demo and it works fine. But what I can make out of your defines is that you are missing one NK_IMPLEMENTATION in one .c/.cpp file. From the Readme:

The implementation mode requires to define the preprocessor macro NK_IMPLEMENTATION in one .c/.cpp file before

(if you don't know what I mean by that please look inside the demo) If this still does not solve the issue it would beneficial for me if you could copy & paste all errors to gist (or somewhere else) and link to so that I can take a look.

KenzieMac130 commented 8 years ago

I commented that part out earlier becuase the description of that made it seem like it was needed specifically for .c/.cpp files, mine is inside a header file so there was a bit of confusion there.

I've defined that variable and it eliminated one of the errors however the other 108 still remain. I guess I will paste in the following errors in a separate message.

Just to clarify, my project is not using the DX11 Demo code, I plan on writing it specifically for my engine but I might be missing something in the process that prevents it from compiling.

KenzieMac130 commented 8 years ago

Severity Code Description Project File Line Suppression State Error (active) more than one instance of overloaded function "nk_window_set_size" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 548 Error (active) more than one instance of overloaded function "nk_window_set_position" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 547 Error (active) more than one instance of overloaded function "nk_window_set_bounds" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 546 Error (active) more than one instance of overloaded function "nk_widget_fitting" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 793 Error (active) more than one instance of overloaded function "nk_widget" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 792 Error (active) more than one instance of overloaded function "nk_triangle_from_direction" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 855 Error (active) more than one instance of overloaded function "nk_tree_image_push_hashed" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 586 Error (active) more than one instance of overloaded function "nk_subimage_ptr" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 850 Error (active) more than one instance of overloaded function "nk_subimage_id" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 851 Error (active) more than one instance of overloaded function "nk_style_item_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 2185
Error (active) more than one instance of overloaded function "nk_stroke_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1581
Error (active) more than one instance of overloaded function "nk_stroke_circle" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1582
Error (active) more than one instance of overloaded function "nk_select_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 651 Error (active) more than one instance of overloaded function "nk_select_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 650 Error (active) more than one instance of overloaded function "nk_selectable_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 646 Error (active) more than one instance of overloaded function "nk_selectable_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 645 Error (active) more than one instance of overloaded function "nk_rect_size" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 869 Error (active) more than one instance of overloaded function "nk_rect_pos" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 868 Error (active) more than one instance of overloaded function "nk_recta" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 865 Error (active) more than one instance of overloaded function "nk_push_scissor" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1597
Error (active) more than one instance of overloaded function "nk_popup_begin" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 689 Error (active) more than one instance of overloaded function "nk_menu_item_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 752 Error (active) more than one instance of overloaded function "nk_menu_item_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 751 Error (active) more than one instance of overloaded function "nk_menu_begin_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 744 Error (active) more than one instance of overloaded function "nk_menu_begin_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 745 Error (active) more than one instance of overloaded function "nk_menu_begin_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 743 Error (active) more than one instance of overloaded function "nk_layout_space_to_screen" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 571 Error (active) more than one instance of overloaded function "nk_layout_space_to_local" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 572 Error (active) more than one instance of overloaded function "nk_layout_space_rect_to_screen" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 573 Error (active) more than one instance of overloaded function "nk_layout_space_rect_to_local" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 574 Error (active) more than one instance of overloaded function "nk_layout_space_push" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 567 Error (active) more than one instance of overloaded function "nk_input_mouse_clicked" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1649
Error (active) more than one instance of overloaded function "nk_input_is_mouse_prev_hovering_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1647
Error (active) more than one instance of overloaded function "nk_input_is_mouse_hovering_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1648
Error (active) more than one instance of overloaded function "nk_input_is_mouse_click_in_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1644
Error (active) more than one instance of overloaded function "nk_input_is_mouse_click_down_in_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1645
Error (active) more than one instance of overloaded function "nk_input_has_mouse_click_in_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1642
Error (active) more than one instance of overloaded function "nk_input_has_mouse_click_down_in_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1643
Error (active) more than one instance of overloaded function "nk_input_any_mouse_click_in_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1646
Error (active) more than one instance of overloaded function "nk_image_is_subimage" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 849 Error (active) more than one instance of overloaded function "nk_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 599 Error (active) more than one instance of overloaded function "nk_font_bake_pack" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1366
Error (active) more than one instance of overloaded function "nk_font_bake_memory" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1365
Error (active) more than one instance of overloaded function "nk_font_bake_custom_data" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1368
Error (active) more than one instance of overloaded function "nk_font_bake" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1367
Error (active) more than one instance of overloaded function "nk_font_atlas_add_from_memory" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1343
Error (active) more than one instance of overloaded function "nk_font_atlas_add_from_file" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1345
Error (active) more than one instance of overloaded function "nk_font_atlas_add_default" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1341
Error (active) more than one instance of overloaded function "nk_font_atlas_add_compressed_base85" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1348
Error (active) more than one instance of overloaded function "nk_font_atlas_add_compressed" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1347
Error (active) more than one instance of overloaded function "nk_font_atlas_add" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1339
Error (active) more than one instance of overloaded function "nk_fill_rect_multi_color" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1590
Error (active) more than one instance of overloaded function "nk_fill_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1589
Error (active) more than one instance of overloaded function "nk_fill_circle" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1591
Error (active) more than one instance of overloaded function "nk_draw_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1599
Error (active) more than one instance of overloaded function "nk_draw_list_stroke_triangle" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1751
Error (active) more than one instance of overloaded function "nk_draw_list_stroke_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1750
Error (active) more than one instance of overloaded function "nk_draw_list_stroke_poly_line" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1754
Error (active) more than one instance of overloaded function "nk_draw_list_stroke_line" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1749
Error (active) more than one instance of overloaded function "nk_draw_list_stroke_curve" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1753
Error (active) more than one instance of overloaded function "nk_draw_list_stroke_circle" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1752
Error (active) more than one instance of overloaded function "nk_draw_list_path_rect_to" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1743
Error (active) more than one instance of overloaded function "nk_draw_list_path_line_to" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1740
Error (active) more than one instance of overloaded function "nk_draw_list_path_curve_to" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1744
Error (active) more than one instance of overloaded function "nk_draw_list_path_arc_to_fast" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1741
Error (active) more than one instance of overloaded function "nk_draw_list_path_arc_to" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1742
Error (active) more than one instance of overloaded function "nk_draw_list_fill_triangle" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1759
Error (active) more than one instance of overloaded function "nk_draw_list_fill_rect_multi_color" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1758
Error (active) more than one instance of overloaded function "nk_draw_list_fill_rect" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1757
Error (active) more than one instance of overloaded function "nk_draw_list_fill_poly_convex" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1761
Error (active) more than one instance of overloaded function "nk_draw_list_fill_circle" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1760
Error (active) more than one instance of overloaded function "nk_draw_list_add_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1765
Error (active) more than one instance of overloaded function "nk_draw_list_add_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1764
Error (active) more than one instance of overloaded function "nk_draw_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1598
Error (active) more than one instance of overloaded function "nk_contextual_item_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 727 Error (active) more than one instance of overloaded function "nk_contextual_item_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 726 Error (active) more than one instance of overloaded function "nk_contextual_begin" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 723 Error (active) more than one instance of overloaded function "nk_combo_item_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 716 Error (active) more than one instance of overloaded function "nk_combo_item_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 715 Error (active) more than one instance of overloaded function "nk_combo_begin_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 712 Error (active) more than one instance of overloaded function "nk_combo_begin_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 711 Error (active) more than one instance of overloaded function "nk_combo_begin_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 710 Error (active) more than one instance of overloaded function "nk_button_image_text" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 624 Error (active) more than one instance of overloaded function "nk_button_image_label" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 623 Error (active) more than one instance of overloaded function "nk_button_image" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 620 Error (active) more than one instance of overloaded function "nk_begin" has 'C' linkage astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 522 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 527 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 528 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 532 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 533 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 534 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 535 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 570 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 783 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 784 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 785 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 847 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 848 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 857 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 858 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 859 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 860 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 862 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 863 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 864 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 866 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 867 Error (active) cannot overload functions distinguished by return type alone astrengine f:\alpha\astrengine\include\nuklear\nuklear.h 1338

vurtun commented 8 years ago

Could you try the following. Inside your header copy this into

NK_INCLUDE_FIXED_TYPES
NK_INCLUDE_STANDARD_IO
NK_INCLUDE_DEFAULT_ALLOCATOR
NK_INCLUDE_VERTEX_BUFFER_OUTPUT
NK_INCLUDE_FONT_BAKING
NK_INCLUDE_DEFAULT_FONT
#include "nuklear.h"

and in any other *.c file copy this into:

NK_IMPLEMENTATION
NK_INCLUDE_FIXED_TYPES
NK_INCLUDE_STANDARD_IO
NK_INCLUDE_DEFAULT_ALLOCATOR
NK_INCLUDE_VERTEX_BUFFER_OUTPUT
NK_INCLUDE_FONT_BAKING
NK_INCLUDE_DEFAULT_FONT
#include "nuklear.h"
KenzieMac130 commented 8 years ago

Sorry for the dellay. I'm still getting those errors. I tried following the instructions as best as I could (there is now a .cpp file with NK_IMPLIMENTATION and the .h file includes the rest of them) but just to be sure: I am supposed to add the nuklear.h to my include directory right? so not in the source code? because my program is giving me some bizarre unresolved external symbol errors in the .obj linking stage (I'm not sure if it even should be there). I tried to do a basic color declaration before going too far into implementation just to make sure the library worked in the project but that ended up with this: error LNK2001: unresolved external symbol _nk_rgb (I used the _nk_rgb variable as a test in another function that just declares a color) Here is what my setup looks like: enginenuklearimplimentation

vurtun commented 8 years ago

I am supposed to add the nuklear.h to my include directory right?

No don't compile the header file, only generate the implementation into another *.c file and compile that file. But I don't know if it is a typo but you wrote NK_IMPLIMENTATION instead of NK_IMPLEMENTATION in your defines.

KenzieMac130 commented 8 years ago

No don't compile the header file

That's what I thought, I just wasn't sure what to do at this point. Admittedly that would have been an unusual library design decision, but so is forcing the user to rewrite the foundation of a program to adhere to the way library wants to be set up. (Cough... Qt)

But I don't know if it is a typo but you wrote NK_IMPLIMENTATION instead of NK_IMPLEMENTATION in your defines.

................................................ (those are copied directly from the header and c++ file, and that solved just about everything) Welp, sorry for wasting your time with this. I cannot believe I overlooked that. I was just about to try and dissect the examples to try to figure out what was different in the project configuration but that fixed all of the errors I was getting.

I did however encounter a minor error with "memset" however that was fixed by adding #define NK_MEMSET std::memset To my .h and .cpp file.

Thank you.