Hi Wen-Yi!



 wayne391:

I found it’s because of missing dynamic libraries in libtorch, but I cannot assume everyone has it.
I think the possible solutions are:

compile the program by static linking.
include the .dll/.dylib with the program

I am not familiar with C++.  Are the proposed solutions correct?


[Disclaimer:  I have neither built torch nor pytorch.]
Yes, these are the two methods you can use to make your program
portable.  Note, you can use a mixture of the two methods – statically
link to some libraries, and provide dynamic libraries for other libraries.


If so, how to achieve that, or what flags and path should I set in the CMAKE?


I don’t know.  I’ve never used CMAKE.


I want my program being portable and no need to install extra dependencies on new computers.


Please note that for portability, you will have to build your program
separately for each operating system you want to run on, and
possibly for different hardware platforms and different versions of
the same operating system.
You would normally do this by building on each of the platforms you
want to run on.  (You can also “cross-compile” and “cross-build,” but
that is an art in itself.)
If you want your program to be casually portable, you can build on
your target systems, and hope for the best.  If you want it to be
commercial-grade portable, you must test, test, test on various
combinations of operating system, hardware, and version and
configuration of operating system.  For commercial-grade portability
you will probably also want to distribute your program as installers
and package-manager packages appropriate for your target systems.
Good luck!
K. Frank