I have a project that has some main.cpp
and the following precompile header:
<!-- language: lang-cpp -->
#ifndef PRECOMPILE_H
#define PRECOMPILE_H
#include <iostream>
#include <string>
#include <vector>
#include <boost\asio.hpp>
#include <boost\bind.hpp>
#include <boost\asio\ssl.hpp>
#include <boost\locale.hpp>
#include <boost\algorithm\string.hpp>
#endif
If the project is *.lib
, it always builds normally.
If project the is *.exe
:
When build with Create (/Yc)
, all ok.
When setting Use (/Yu)
I get linker error LNK2001
:
1) unresolved external symbol "private: static class boost::asio::detail::tss_ptr::context> boost::asio::detail::call_stack::top_" (?top_@?$call_stack@Vstrand_impl@strand_service@detail@asio@boost@@E@detail@asio@boost@@0V?$tss_ptr@Vcontext@?$call_stack@Vstrand_impl@strand_service@detail@asio@boost@@E@detail@asio@boost@@@234@A)
2) unresolved external symbol "public: static class boost::asio::detail::service_id boost::asio::detail::service_base::id" (?id@?$service_base@Vselect_reactor@detail@asio@boost@@@detail@asio@boost@@2V?$service_id@Vselect_reactor@detail@asio@boost@@@234@A)
3) unresolved external symbol "public: static class boost::asio::detail::service_id boost::asio::detail::service_base::id" (?id@?$service_base@Vstrand_service@detail@asio@boost@@@detail@asio@boost@@2V?$service_id@Vstrand_service@detail@asio@boost@@@234@A)
4) unresolved external symbol "public: static class boost::asio::detail::service_id > > boost::asio::detail::service_base > >::id" (?id@?$service_base@V?$deadline_timer_service@Vptime@posix_time@boost@@U?$time_traits@Vptime@posix_time@boost@@@asio@3@@asio@boost@@@detail@asio@boost@@2V?$service_id@V?$deadline_timer_service@Vptime@posix_time@boost@@U?$time_traits@Vptime@posix_time@boost@@@asio@3@@asio@boost@@@234@A)
Boost: v1_49 static /MTd
If your precompiled header is called PCH.H
you also should have a PCH.CPP
file that gets compiled with /Yc
and linked (as PCH.OBJ
) to all the others that you compile with /Yu
.
For the other cases that work, perhaps this is because nothing static
from the Boost headers has to get exported from the precompiled header object file.