Trying to load C++ Boost 1.47.0 in VS
Trying to add the C++ Archive Boost library 1.47.0 in VS using "Properties", "VC++ directory, Library Directories. Attached is the header file and attached are pictures of both the file and directory insert which is listed as C:\boost. Result is VS says it cannot open the file.
serial.h
include <boost/asio.hpp>
include <string>
using namespace boost::asio;
class Serial
{
private:
io_service _io;
serial_port _serial;
unsigned int _BaudRate
std::string _COM;
public:
Serial(std::string port, unsigned int BaudRate);
size_t transmit(uint8_t* s,size_t len);
};
Developer technologies | Visual Studio | Other
-
David Lowndes • 4,726 Reputation points
2022-07-27T15:03:04.627+00:00 Is it saying it can't find asio.hpp?
Try adding the boost include directory path to "Include Directories" -
CG Stroh • 21 Reputation points
2022-07-27T16:16:36.043+00:00 Same result with include directory. It is not saying it cannot find the file, it says it cannot open the file.
-
CG Stroh • 21 Reputation points
2022-07-27T16:52:29.13+00:00 I was trying to follow instructions from someone online but I cannot understand what is meant by item #4;
- Right click on project and select Properties
- Common Properties => VC++ Directories
- Include Directories => add the directory where you installed boost libraries.
- Library Directories => " " where you built " " .
-
David Lowndes • 4,726 Reputation points
2022-07-27T16:59:27.217+00:00 Which file? Show the exact error message so there's no guessing.
-
CG Stroh • 21 Reputation points
2022-07-27T17:47:34.393+00:00 in the lower left of the above picture is the error message. To the right is the path in the "include directory".
-
David Lowndes • 4,726 Reputation points
2022-07-27T19:30:57.283+00:00 Include Directories is meant to be the directory, not the file, and you'll only need to use #include <asio.hpp> with where you've put boost.
-
CG Stroh • 21 Reputation points
2022-07-27T20:12:31.64+00:00 Actually, the one I just sent you was the first time I included the asio.hpp at the end of the path. Before I simply had used C:\boost and that did not work either.
-
David Lowndes • 4,726 Reputation points
2022-07-27T20:14:23.303+00:00 Read the last part of my last sentence.
-
CG Stroh • 21 Reputation points
2022-07-27T21:29:23.493+00:00 By directory we mean the path to boost - C:\boost? What is meant by your statement "only need to use #include <asio.hpp> with where you've put boost"?
-
David Lowndes • 4,726 Reputation points
2022-07-27T21:43:44.897+00:00 You have: #include <boost/asio.hpp>
Change it to: #include <asio.hpp>
and see if that works. -
CG Stroh • 21 Reputation points
2022-07-27T23:18:52.92+00:00 It fixed part of the problem. Attached is a picture of the remaining errors. It appears that making the change you suggested opened the file asio.hpp but did not open the folder that asio.hpp refers to. Below is a brief copy of what is in the file asio.hpp:
asio.hpp
//
ifndef BOOST_ASIO_HPP
define BOOST_ASIO_HPP
if defined(_MSC_VER) && (_MSC_VER >= 1200)
pragma once
endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
include <boost/asio/basic_datagram_socket.hpp>
include <boost/asio/basic_deadline_timer.hpp>
include <boost/asio/basic_io_object.hpp>
include <boost/asio/basic_raw_socket.hpp>
include <boost/asio/basic_seq_packet_socket.hpp>
include <boost/asio/basic_serial_port.hpp>
include <boost/asio/basic_signal_set.hpp>
include <boost/asio/basic_socket_acceptor.hpp>
include <boost/asio/basic_socket_iostream.hpp>
include <boost/asio/basic_socket_streambuf.hpp>
include <boost/asio/basic_stream_socket.hpp>
include <boost/asio/basic_streambuf.hpp>
include <boost/asio/buffer.hpp>
include <boost/asio/buffered_read_stream_fwd.hpp>
include <boost/asio/buffered_read_stream.hpp>
include <boost/asio/buffered_stream
All these files are in the folder asio inside the boost folder. The boost folder holds both the asio.hpp file and the folder asio.
-
CG Stroh • 21 Reputation points
2022-07-27T23:26:26.377+00:00 It fixed part of the problem. Attached is a picture of the remaining errors. It appears that making the change you suggested opened the file asio.hpp but did not open the folder that asio.hpp refers to. Below is a brief copy of what is in the file asio.hpp:
asio.hpp
//
ifndef BOOST_ASIO_HPP
define BOOST_ASIO_HPP
if defined(_MSC_VER) && (_MSC_VER >= 1200)
pragma once
endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
include <boost/asio/basic_datagram_socket.hpp>
include <boost/asio/basic_deadline_timer.hpp>
include <boost/asio/basic_io_object.hpp>
include <boost/asio/basic_raw_socket.hpp>
include <boost/asio/basic_seq_packet_socket.hpp>
include <boost/asio/basic_serial_port.hpp>
include <boost/asio/basic_signal_set.hpp>
include <boost/asio/basic_socket_acceptor.hpp>
include <boost/asio/basic_socket_iostream.hpp>
include <boost/asio/basic_socket_streambuf.hpp>
include <boost/asio/basic_stream_socket.hpp>
include <boost/asio/basic_streambuf.hpp>
include <boost/asio/buffer.hpp>
include <boost/asio/buffered_read_stream_fwd.hpp>
include <boost/asio/buffered_read_stream.hpp>
include <boost/asio/buffered_stream
All these files are in the folder asio inside the boost folder. The boost folder holds both the asio.hpp file and the folder asio.
-
David Lowndes • 4,726 Reputation points
2022-07-28T08:25:21.397+00:00 I think the problems you're having are due to installing boost in an unconventional manner.
Start with a clean sheet and see if following the information here helps https://www.boost.org/doc/libs/1_79_0/more/getting_started/windows.html -
CG Stroh • 21 Reputation points
2022-07-28T13:56:06.147+00:00 Good morning!
I followed the script with two exceptions, they are using boost version 1.79 and I am using version1.47 and secondly they describe in Configuration Properties>C/C++>Precompiled headers, change Us e Precompiled Header to Not using Precompiled Headers. I could not find this listing. End result is VS says Unknown compiler version; run configure tests and report results. I cannot find "configure tests" -
CG Stroh • 21 Reputation points
2022-07-28T14:26:34.683+00:00 Correction, found the second item and it was already not using precompiled headers. So is it just the 1.47 version versus the 1.79 version that is the issue? Surely that would not cause an unknown compiler?
rsion
-
David Lowndes • 4,726 Reputation points
2022-07-28T14:34:48.557+00:00 See if this helps https://stackoverflow.com/questions/47004187/visual-studio-unknown-compiler-version-after-upgrading
Advice seems to be to use a newer version of boost. -
RLWA32 • 49,636 Reputation points
2022-07-28T14:38:18.887+00:00 Boost 1.47.0 was released over 10 years ago. At the time it was released the then most current version of VC++ against which it was tested was 2010. Sorry, no time travel here -- the version of VC++ you are using did not exist when Boost 1.47.0 was released.
Anyway, why are you using this old version instead of the current one?
-
CG Stroh • 21 Reputation points
2022-07-28T19:53:10.36+00:00 Okay we have replaced the boost file with 1.79.0. We get no errors but the program behaves funny. The instructions are to press the F5 key, this opens a window but you cannot type anything in. If you use the normal control-F5 you get a window that you can type in. Using the recommended 1 2 3 return, you get the number 369. Not sure what the right answer is. Adding the control "Z" closes the program.
Now there are a few differences between this example program and the one I wish to run. In the example, the #include <boost/lambda/lambda.hpp> works because the lambda.hpp file is in the lambda folder. In the program I wish to run, the asio.hpp file is not in the asio folder. So I suspect using #include <boost/asio/asio.hpp> is not going to work. I can put the asio.hpp file in the asio folder but I do not know if that will mess something else up. Attached is a picture of the example info.
-
David Lowndes • 4,726 Reputation points
2022-07-28T20:10:16.84+00:00 Don't move the boost header files from where the installation puts them - your program should #include them from where they are.
Sign in to comment