Compilation error: ‘symlink’ was not declared in this scope
When compiling under Cygwin with the latest code from git (as of August 10, 2020), I get:
Fileinfo.cc:279:14: error: ‘symlink’ was not declared in this scope
Full session:
$ ./bootstrap.sh
it seems like everything went fine. now try
./configure && make
$ ./configure
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 for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of g++... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking how to run the C++ preprocessor... g++ -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
no
checking whether to enable assertions... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking nettle/sha.h usability... yes
checking nettle/sha.h presence... yes
checking for nettle/sha.h... yes
checking for main in -lnettle... yes
checking for stat... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
configure: checking for c++ 11, disable with --disable-cppstandardcheck
checking whether g++ supports C++11 features with -std=c++11... yes
checking check for fallthrough support... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
$ make
make all-am
make[1]: Entering directory '/home/▒▒▒/build/rdfind'
g++ -std=c++11 -DHAVE_CONFIG_H -I. -g -O2 -MT rdfind.o -MD -MP -MF .deps/rdfind.Tpo -c -o rdfind.o rdfind.cc
mv -f .deps/rdfind.Tpo .deps/rdfind.Po
g++ -std=c++11 -DHAVE_CONFIG_H -I. -g -O2 -MT Checksum.o -MD -MP -MF .deps/Checksum.Tpo -c -o Checksum.o Checksum.cc
mv -f .deps/Checksum.Tpo .deps/Checksum.Po
g++ -std=c++11 -DHAVE_CONFIG_H -I. -g -O2 -MT Dirlist.o -MD -MP -MF .deps/Dirlist.Tpo -c -o Dirlist.o Dirlist.cc
mv -f .deps/Dirlist.Tpo .deps/Dirlist.Po
g++ -std=c++11 -DHAVE_CONFIG_H -I. -g -O2 -MT Fileinfo.o -MD -MP -MF .deps/Fileinfo.Tpo -c -o Fileinfo.o Fileinfo.cc
Fileinfo.cc: In lambda function:
Fileinfo.cc:279:14: error: ‘symlink’ was not declared in this scope
279 | return symlink(target.c_str(), filename.c_str());
| ^~~~~~~
Fileinfo.cc: In instantiation of ‘int {anonymous}::transactional_operation(const string&, const Func&) [with Func = Fileinfo::makesymlink(const Fileinfo&)::<lambda(const string&)>; std::string = std::basic_string<char>]’:
Fileinfo.cc:280:6: required from here
Fileinfo.cc:249:20: error: void value not ignored as it ought to be
249 | const int ret = f(filename);
| ~^~~~~~~~~~
make[1]: *** [Makefile:657: Fileinfo.o] Error 1
make[1]: Leaving directory '/home/▒▒▒/build/rdfind'
make: *** [Makefile:536: all] Error 2
edit Makefile remove -std=c++11 then make clean ; make ... not sure if this will break something ..
CXX = g++ -std=c++11 CXXCPP = g++ -E -std=c++11
I did this on MSYS2, but I think it's the same on Cygwin. Apparently the GNU extensions are needed for this. So instead of -std=c++11, you need to replace it with -std=gnu++11.
This can be done by changing line 74 in configure.ac from AX_CXX_COMPILE_STDCXX([11],[noext],[mandatory]) to AX_CXX_COMPILE_STDCXX([11],[ext],[mandatory]). Then rerun ./bootstrap.sh, ./configure, make.
@pauldreik, any reason not to use ext instead of noext, and can you change this?
Sorry for the late reply. Does this happen with the latest devel? I removed the configure.ac macro for C++11.
Related, would you be interested in providing a github action which test compiles rdfind for cygwin? That would be great. I don't normally use windows.
Hi Paul, with the latest main and devel this doesn't happen. Due to the removal of that check -std=c++11 is no longer added to CXXFLAGS and the default g++ that is used contains the extensions :).
Note that this problem is still present in some of the test scripts, for example do_quality_checks.sh, where c++$std should be replaced by gnu++$std in various places to avoid the problem in this issue.
I have not used Github Actions before, but it doesn't seem to be too difficult to figure out. I'll give it a shot, but I expect that it'll be some time before I have enough spare time to dedicate to testing it.
Good that the issue is gone.
I am not a fan of extensions, hence the urge to adhere as close as possible to the standard. I am not sure why the extensions are needed, see the related work in https://github.com/pauldreik/rdfind/pull/39