How to use a library of C++ 20 modules from another solution file?


I have a library of C++ 20 modules which I can use from projects in the same solution but not from projects in another solution.
I have instructed the linker to link the static library but it does not find the modules...

Please help!

if its meant to be reused you need to get it out of the solution folder and up into a shared folder. I do not know if there is a standard place for modules like <src> and so on folder names or if they just go in the standard source/header folders, but you want a common place for any and all reusable code (can have subfolders if large) and pull it from there.

if there are compiled files you put those in a similar seen by all / shared by all folder for "library" or lib or whatever folder name.

"solutions" is a made up thing from microsoft, when a dev got confused one night after a bender and forgot he was doing computer science instead of chemistry. Its just like a project file or makefile of settings and folders and files that are used in building it. But the IDE has a very bad habit of creating new files that you write IN that 'solution' folder where its hard to reuse it. Just move it and then point the existing broken project back to the new location and it will straighten out... it should be obvious what to do but if you can't get it working ask again?
You mean top create a Shared Items Project in the solution?
that may work, but no, I mean pure windows folder management. You should be able to locate the files associated with any module you wrote or downloaded and move them to a place that you can use them from in all your projects. It sounds like they live inside the 'solution' folder currently, and, on top of that, the library associated with them (if any) may be in the /debug or /release folders. Do you see this when you open the folder in a file viewing window (explorer window)?

once moved, in your IDE settings, you need to configure this:

and you may also need to set All Modules are Public where the module is created.

and you may still need the old dllexport flags on the modules.

It looks to be both confusing (lots to do and much of it seems like it should have been done by default) and simple (its a lot like any DLL or library file setup) at the same time. You may be better off looking up some instructions on all this online -- I have only done the very minimal with modules so far and am far, far from any expert. They work a LOT like a library, but its been slid into the IDE sideways and without following a site with step by step instructions it may be quite difficult to unravel and get working.
Last edited on
Topic archived. No new replies allowed.