libMesh / libmesh

libMesh github repository
http://libmesh.github.io
GNU Lesser General Public License v2.1
658 stars 286 forks source link

how to build source code with cmake? #2964

Open junqiangchen opened 3 years ago

junqiangchen commented 3 years ago

hi,i want use libmesh on win10,the library can build with cmake,just like VTK buid with cmake? thank you

jwpeterson commented 3 years ago

No, libmesh has an autotools-based build system (./configure; make; make install) so you need to use that to build it.

junqiangchen commented 3 years ago

No, libmesh has an autotools-based build system (./configure; make; make install) so you need to use that to build it.

@jwpeterson i use mingw tool build libmesh1.0 on win10 with ./configure,make and make install,but the error is happend on make step,so i want known which version can build on win10?

jwpeterson commented 3 years ago

libmesh-1.0.0 is 5+ years old now so I would first try an up-to-date stable release like 1.6.2. Second, if there is an error during compiling, you should post it here on this issue, as we may then be able to suggest a fix for it.

junqiangchen commented 3 years ago

@jwpeterson ,i use M2sys64 tool build libmesh1.6.2,and using command ./configure --prefix=d:/cjq/project/3dlib/libmesh/install --disable-metis --with-fparser=none,but when make processing,the error happened:

memio.c: In function 'memio_new': memio.c:148:7: error: unknown type name 'SYSTEM_INFO' 148 | SYSTEM_INFO info; | ^~~ memio.c:149:7: warning: implicit declaration of function 'GetSystemInfo' [-Wimplicit-function-declaration] 149 | GetSystemInfo (&info); | ^~~~~ memio.c:150:22: error: request for member 'dwPageSize' in something not a structure or union 150 | pagesize = info.dwPageSize;

how to fix it?

thank you

junqiangchen commented 3 years ago

@jwpeterson i solve the problem from here,but i get new problem

CXXLD libtimpi_dbg.la libtool: error: can't build x86_64-w64-mingw32 shared library unless -no-undefined is specified make[3]: [Makefile:801: libtimpi_dbg.la] Error 1 make[3]: Leaving directory '/d/cjq/project/3dlib/libmesh/libmesh-1.6.2/contrib/timpi/src' make[2]: [Makefile:587: all-recursive] Error 1 make[2]: Leaving directory '/d/cjq/project/3dlib/libmesh/libmesh-1.6.2/contrib/timpi' make[1]: [Makefile:994: all-recursive] Error 1 make[1]: Leaving directory '/d/cjq/project/3dlib/libmesh/libmesh-1.6.2/contrib' make: [Makefile:31943: all-recursive] Error 1

can you tell me how to solve it?

thank you

jwpeterson commented 3 years ago

You may be able to fix this issue by re-configuring with LDFLAGS=-no-undefined appended to your other configure flags... I'm not sure exactly what causes this issue. This doesn't seem to be a linker option on Linux (although --no-undefined, with 2 dashes is) and I have never needed it to build a shared library on Linux.

jwpeterson commented 3 years ago

Looks like a similar issue with MinGW was reported here.

junqiangchen commented 3 years ago

i use the configure commond,but there have C compiler cannot create executables error

./configure --prefix=d:/cjq/project/3dlib/libmesh/install --disable-metis --with-fparser=none --disable-netcdf --disable-netcdf-4 LDFLAGS=-no-undefined

configure: loading site script /etc/config.site

----------- Configuring libMesh -------------

checking build system type... x86_64-w64-mingw32 checking host system type... x86_64-w64-mingw32 checking target system type... x86_64-w64-mingw32 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether UID '197108' is supported by ustar format... yes checking whether GID '197121' is supported by ustar format... yes checking how to create a ustar tar archive... gnutar checking whether make supports nested variables... (cached) yes checking whether to enable maintainer-specific portions of Makefiles... no checking for src/base/libmesh.C... yes checking for perl... /usr/bin/perl note: MPI library path not given... checking for petscarch... no checking whether make supports the include directive... yes (GNU style) checking for mpicc... no checking for gcc... gcc checking whether the C compiler works... no configure: error: in /d/cjq/project/3dlib/libmesh/libmesh-1.6.2': configure: error: C compiler cannot create executables Seeconfig.log' for more details

junqiangchen commented 3 years ago

Looks like a similar issue with MinGW was reported here.

i use make LDFLAGS=-no-undefined commond,there have another error

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src\fe\.libs\libmesh_dbg_la-fe_subdivision_2D.o: in function libMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const*, libMesh::Point const&, double, bool)': D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/src/fe/fe_subdivision_2D.C:944: multiple definition oflibMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const, libMesh::Point const&, double, bool)'; src\fe\.libs\libmesh_dbg_la-fe_interface.o:D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/./include/libmesh/fe.h:422: first defined here C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src\fe\.libs\libmesh_dbg_la-fe_subdivision_2D.o: in function `libMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const, std::vector<libMesh::Point, std::allocator > const&, std::vector<libMesh::Point, std::allocator >&, double, bool)': D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/src/fe/fe_subdivision_2D.C:954: multiple definition of `libMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const*, std::vector<libMesh::Point, std::allocator > const&, std::vector<libMesh::Point, std::allocator >&, double, bool)'; src\fe\.libs\libmesh_dbg_la-fe_interface.o:D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/./include/libmesh/fe.h:430: first defined here C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: error: export ordinal too large: 69507 collect2.exe: error: ld returned 1 exit status make[1]: [Makefile:9115: libmesh_dbg.la] Error 1 make[1]: Leaving directory '/d/cjq/project/3dlib/libmesh/libmesh-1.6.2' make: [Makefile:31943: all-recursive] Error 1

jwpeterson commented 3 years ago

Your last two comments seem to contradict one another... if running configure really did fail, you cannot proceed to then run "make" ... configure has to run successfully first. As the error message says, we would need to see the config.log file to figure out what led to the C compiler cannot create executables. Presumably this is related to changing the LDFLAGS, but it would be good to confirm this.

junqiangchen commented 3 years ago

Your last two comments seem to contradict one another... if running configure really did fail, you cannot proceed to then run "make" ... configure has to run successfully first. As the error message says, we would need to see the config.log file to figure out what led to the C compiler cannot create executables. Presumably this is related to changing the LDFLAGS, but it would be good to confirm this.

i forget supply configure commond,first i use ./configure --prefix=d:/cjq/project/3dlib/libmesh/install --disable-metis --with-fparser=none --disable-netcdf --disable-netcdf-4 commond. .............

Configure complete, now type 'make' and then 'make install'.


--------- Done Configuring libMesh ----------

second,i use make LDFLAGS=-no-undefined commond C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src\fe\.libs\libmesh_dbg_la-fe_subdivision_2D.o: in function libMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const*, libMesh::Point const&, double, bool)': D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/src/fe/fe_subdivision_2D.C:944: multiple definition oflibMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const, libMesh::Point const&, double, bool)'; src\fe\.libs\libmesh_dbg_la-fe_interface.o:D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/./include/libmesh/fe.h:422: first defined here C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src\fe\.libs\libmesh_dbg_la-fe_subdivision_2D.o: in function `libMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const, std::vector<libMesh::Point, std::allocator > const&, std::vector<libMesh::Point, std::allocator >&, double, bool)': D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/src/fe/fe_subdivision_2D.C:954: multiple definition of `libMesh::FE<2u, (libMesh::FEFamily)23>::inverse_map(libMesh::Elem const*, std::vector<libMesh::Point, std::allocator > const&, std::vector<libMesh::Point, std::allocator >&, double, bool)'; src\fe\.libs\libmesh_dbg_la-fe_interface.o:D:\cjq\project\3dlib\libmesh\libmesh-1.6.2/./include/libmesh/fe.h:430: first defined here C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: error: export ordinal too large: 69507 collect2.exe: error: ld returned 1 exit status make[1]: [Makefile:9115: libmesh_dbg.la] Error 1 make[1]: Leaving directory '/d/cjq/project/3dlib/libmesh/libmesh-1.6.2' make: [Makefile:31943: all-recursive] Error 1