Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Linking in the std library
Linking in the std library [message #60718] Wed, 31 July 2024 22:23 Go to next message
awksed is currently offline  awksed
Messages: 70
Registered: April 2012
Member
To use the chrono library (which needs C++ 20) in older projects I built a static library in VS 2022.

Linking in my static lib to a U++ console project I get the following error (and other similar):

unresolved external symbol "public: static unsigned int const * const std::_General_precision_tables_2<float>::_Ordinary_X_table "

This is probably related to the use of std::format().

How can I link in the appropriate library or source?

Windows 10
U++ 17045
MSVS22x64

Thanks.
Re: Linking in the std library [message #60719 is a reply to message #60718] Thu, 01 August 2024 08:16 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3437
Registered: August 2008
Senior Veteran
Sorry Awksed, are you referring to std::chrono?

Best regards
Iñaki
Re: Linking in the std library [message #60720 is a reply to message #60719] Thu, 01 August 2024 09:44 Go to previous messageGo to next message
awksed is currently offline  awksed
Messages: 70
Registered: April 2012
Member
Hi Iñak,

Yes it's std:chrono.
Re: Linking in the std library [message #60727 is a reply to message #60720] Sun, 04 August 2024 17:08 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3437
Registered: August 2008
Senior Veteran
Hi Awksed

I have tried the code in the second answer here (enclosed below) and it has worked in CLANG (W10 and W11) and MSVC (W10):

#include <iostream>
#include <chrono>
#include <thread>

int main()
{
    using namespace std::literals;
    namespace chrono = std::chrono;
    using clock_type = chrono::high_resolution_clock;

    auto start = clock_type::now();

    for(;;) {
        auto first = clock_type::now();

        // note use of literal - this is c++14
        std::this_thread::sleep_for(500ms);

        // c++11 would be this:
        //        std::this_thread::sleep_for(chrono::milliseconds(500));

        auto last = clock_type::now();
        auto interval = last - first;
        auto total = last - start;

        // integer cast
        std::cout << "we just slept for " << chrono::duration_cast<chrono::milliseconds>(interval).count() << "ms\n";

        // another integer cast
        std::cout << "also known as " << chrono::duration_cast<chrono::nanoseconds>(interval).count() << "ns\n";

        // floating point cast
        using seconds_fp = chrono::duration<double, chrono::seconds::period>;
        std::cout << "which is " << chrono::duration_cast<seconds_fp>(interval).count() << " seconds\n";

        std::cout << "  total time wasted: " << chrono::duration_cast<chrono::milliseconds>(total).count() << "ms\n";
        std::cout << "         in seconds: " << chrono::duration_cast<seconds_fp>(total).count() << "s\n";


        std::cout << std::endl;
    }
    return 0;
}


Best regards
Iñaki
Re: Linking in the std library [message #60730 is a reply to message #60718] Mon, 05 August 2024 18:46 Go to previous messageGo to next message
awksed is currently offline  awksed
Messages: 70
Registered: April 2012
Member
Hi Iñak,

My problem is with a static library. An exe will build ok as in your reply.

I fixed the problem by eliminating str:formt() from the library.

Many thanks for your reply.
Re: Linking in the std library [message #60731 is a reply to message #60730] Tue, 06 August 2024 14:37 Go to previous message
koldo is currently offline  koldo
Messages: 3437
Registered: August 2008
Senior Veteran
Perfect.

In your query I didn't realise that you had compiled your library, which uses std::chrono, as a static library, not that you had done a static compilation.
It's been so long since I've done it, I hadn't thought about it.


Best regards
Iñaki
Previous Topic: Shell variable substitution in package configuration flags
Next Topic: 17045 now refuses to build
Goto Forum:
  


Current Time: Sat Jul 05 09:15:35 CEST 2025

Total time taken to generate the page: 0.03737 seconds