Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure fails on checking libiconv #491

Closed
masahito-yamaga opened this issue Sep 17, 2023 · 10 comments · Fixed by #497
Closed

configure fails on checking libiconv #491

masahito-yamaga opened this issue Sep 17, 2023 · 10 comments · Fixed by #497
Assignees

Comments

@masahito-yamaga
Copy link

masahito-yamaga commented Sep 17, 2023

I think the following patch is needed. After patching, execute autoreconf.

--- ./macros/iconv.m4.ORG	2023-09-11 02:55:05.000000000 +0900
+++ ./macros/iconv.m4	2023-09-17 07:59:29.209441797 +0900
@@ -40,14 +40,15 @@
   esac

 	AC_CACHE_CHECK([for libiconv],netatalk_cv_iconv,[
-          AC_LINK_IFELSE([AC_LANG_SOURCE([[
+          AC_LINK_IFELSE([AC_LANG_SOURCE([
 #include <stdlib.h>
 #include <iconv.h>
-],[
+int main(void) {
 	iconv_t cd = iconv_open("","");
         iconv(cd,NULL,NULL,NULL,NULL);
         iconv_close(cd);
-]])], netatalk_cv_iconv=yes, netatalk_cv_iconv=no, netatalk_cv_iconv=cross)])
+}
+])], netatalk_cv_iconv=yes, netatalk_cv_iconv=no, netatalk_cv_iconv=cross)])

 	if test x"$netatalk_cv_iconv" = x"yes"; then
 	    ICONV_LIBS="$ICONV_LIBS -liconv"
@rdmark
Copy link
Member

rdmark commented Sep 18, 2023

@masahito-yamaga Thank you for reporting!

May I ask which OS that you are using?

I tested on Debian 12, FreeBSD and OpenIndiana, but I couldn't observe a difference in behavior after applying your patch.

checking for libiconv... no
checking for working iconv... yes
checking whether iconv supports UCS-2-INTERNAL... no

I'm sure there's something obvious I'm missing here

@masahito-yamaga
Copy link
Author

Very old Linux Box.

Kernel 2.6.22.7 + uClibc + gcc 8.5.0

@masahito-yamaga
Copy link
Author

masahito-yamaga commented Sep 18, 2023

configure with "--with-libiconv=/opt/local" fails and terminates like:

checking for libiconv... no
configure: error: libiconv not found

In config.log,

configure:16686: checking for libiconv
configure:16704: gcc -o conftest -I/opt/local/include -D_U_="__attribute__((unused))" -g -O2 -I/opt/local/include -L/opt/local/lib -Wl,-rpath -Wl,
/opt/local/lib:/opt/lib -L/opt/local/lib -liconv conftest.c  >&5
conftest.c:78:1: error: expected identifier or '(' before ',' token
 ,
 ^
conftest.c:80:18: error: expected ')' before '(' token
         iconv(cd,NULL,NULL,NULL,NULL);
                  ^
                  )
conftest.c:81:9: warning: parameter names (without types) in function declaration
         iconv_close(cd);
         ^~~~~~~~~~~
configure:16704: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "netatalk"

(snip)

| #define NDEBUG 1
| /* end confdefs.h.  */
|
| #include <stdlib.h>
| #include <iconv.h>
| ,
|       iconv_t cd = iconv_open("","");
|         iconv(cd,NULL,NULL,NULL,NULL);
|         iconv_close(cd);
|
configure:16713: result: no
configure:16724: error: libiconv not found

@rdmark
Copy link
Member

rdmark commented Sep 18, 2023

That explains it. This must mean your version of Linux doesn't have native iconv in glibc but relies on libiconv

@masahito-yamaga
Copy link
Author

No.
Would you please look at my post carefully?
My patch works correctly.

@masahito-yamaga
Copy link
Author

masahito-yamaga commented Sep 18, 2023

The original configure creates the following temporary program that cannot be compiled.

#include <stdlib.h>
#include <iconv.h>
,
      iconv_t cd = iconv_open("","");
        iconv(cd,NULL,NULL,NULL,NULL);
        iconv_close(cd);

But after applying my patch (and then executing autoreconf), configure creates the following one.

#include <stdlib.h>
#include <iconv.h>
int main(void) {
      iconv_t cd = iconv_open("","");
        iconv(cd,NULL,NULL,NULL,NULL);
        iconv_close(cd);
}

The above can be compiled and configure does not fail.

checking for libiconv... yes
checking for working iconv... yes
checking whether iconv supports UCS-2-INTERNAL... yes

@rdmark
Copy link
Member

rdmark commented Sep 18, 2023

I get it now, thanks. I can see how the syntax is wrong in the current program.

Would you be able to create a Pull Request here in github, so that a project member can approve and merge the change?

@masahito-yamaga
Copy link
Author

masahito-yamaga commented Sep 18, 2023

Thank you for your understanding.
But I am not familiar with Pull Requests, so would you please do it for me?

@rdmark
Copy link
Member

rdmark commented Sep 18, 2023

We are happy to help. Please bear in mind that it takes a little longer time, since one project member has to create the PR, and another one approve the merge, as per the project policy.

If you ever feel like getting to know the code contribution workflow in GitHub, we have a manual written here: https://github.com/Netatalk/netatalk/wiki/Developer-Notes#user-content-Code_Contribution_Process

@dgsga dgsga self-assigned this Sep 18, 2023
@dgsga dgsga linked a pull request Sep 19, 2023 that will close this issue
@rdmark
Copy link
Member

rdmark commented Sep 20, 2023

Out of curiosity I checked what iconv test program is generated with the netatalk 2.2 branch:

#include <stdlib.h>
#include <iconv.h>

int
main ()
{

      iconv_t cd = iconv_open("","");
        iconv(cd,NULL,NULL,NULL,NULL);
        iconv_close(cd);

  ;
  return 0;
}

A little messy syntax, but the program does compile, with a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants