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

Can't compile example in Visual Studio 2019 #50

Open
purpledan opened this issue Mar 26, 2021 · 4 comments
Open

Can't compile example in Visual Studio 2019 #50

purpledan opened this issue Mar 26, 2021 · 4 comments

Comments

@purpledan
Copy link

Hello there,

I have managed to build the project using cmake and MSVC, I could open the examples and even make small changes. However, when I create a new project, copy the hello.cpp to my project, set the include path and the lib path it fails to compile giving me these errors:

1>Tvision3.cpp 1>C:\Users\%username%\source\tvision-master\include\tvision\tv.h(35,9): warning C4068: unknown pragma 'option' 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\limits(44,67): error C2864: 'std::_Num_base::has_denorm': a static data member with an in-class initializer must have non-volatile const integral type or be specified as 'inline' 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\limits(44,67): message : type is 'std::float_denorm_style' 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\limits(45,59): error C2864: etc. etc.

I would really like to use this library as I love CLI interfaces, I am currently working on a project for my university to create a unified interface for all our vacuum gauges. So far I have managed to do it well on Labview but I would like to build everything using Turbo Vision. Not only would it mean a great relief or resources compared to the bloat that is Labview, but CLI may also be used via SSL.

Any advice on how to overcome this issue would be greatly appreciated.

@magiblot
Copy link
Owner

Hello purpledan,

Can I see what's in your Tvision3.cpp file? (At least up to the point where <tvision/tv.h> is included)

@magiblot
Copy link
Owner

magiblot commented Mar 26, 2021

Okay, I know what's wrong. You need to enable the /Zc:__cplusplus compilation flag, and possibly also /permissive-.

The build fails because the CMake configuration files in Turbo Vision (CMakeLists.txt) specify compilation flags which are used when building with CMake, but not if you create a new project in Visual Studio and then add the cpp files manually.

Note that Visual Studio allows opening CMake projects directly. Check this out: https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-160. So you can manage your project's compilation settings with CMake and also use Visual Studio to edit code and debug. I recommend you to do this instead of configuring everything in Visual Studio.

If you are not familiar with CMake you may have to spend some effort in learning it, but I think it's worth it.

Let's assume your project consists only of the hello.cpp file you tried to compile earlier. You would create a new directory for your project and put hello.cpp in it. Then, you can write a CMakeLists.txt file similar to this:

cmake_minimum_required (VERSION 3.5) # This can be raised later if you run into issues.

# Use whatever project name you want
project(gaugevision)

# Define output executable and source files
add_executable(hello hello.cpp)

# Import project tvision
add_subdirectory(<path to tvision folder>)

# The 'hello' executable depends on tvision. This will automatically configure the compilation flags
# and include directories necessary for 'hello' to compile successfully.
target_link_libraries(hello PRIVATE tvision)

Note that in the add_subdirectory call you need to specify the path to the directory containing the Turbo Vision repository.

Once your CMakeLists.txt file is ready you should be able to load it into Visual Studio.

Using CMake has several benefits, especially when it comes to portability. But if you still prefer to do everything in Visual Studio (or there is some use case that can only be accomplished with Visual Studio), then you need to add the required compilation flags manually.

@purpledan
Copy link
Author

THAT WORKED PERFECTLY! Thank you so much!

I will look into using cmake especially if it is going to help me with portability. I do not have a specific preference at the moment so I'd like to keep my options open.

I love the name 'GaugeVision' I am so going to use that for my application. If I am successful with the project I will gladly share it with you even if it is just for a screenshot for the github page.

I wonder if others would benefit from this information if they plan on using tvision with Visual studio.

@magiblot
Copy link
Owner

I love the name 'GaugeVision' I am so going to use that for my application. If I am successful with the project I will gladly share it with you even if it is just for a screenshot for the github page.

Haha. I'll look forward to it.

I wonder if others would benefit from this information if they plan on using tvision with Visual studio.

Yes, this is true. I can't expect everybody to use Turbo Vision as a CMake subproject. There have to be clear instructions to use it without CMake.

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

No branches or pull requests

2 participants