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

Trying to build tidy-json.cxx #5

Open
paxperscientiam opened this issue Nov 22, 2018 · 7 comments
Open

Trying to build tidy-json.cxx #5

paxperscientiam opened this issue Nov 22, 2018 · 7 comments
Labels

Comments

@paxperscientiam
Copy link

Hi @geoffmcl , I'm very new to C, so please bear with me. I'm trying to build tidy-json.cxx; however, I'm running into the following error:

➤ c++ tidy-json.cxx
tidy-json.cxx:88:48: error: use of undeclared identifier 'TT_VERSION'
    SPRTF("%s version %s, circa %s\n", module, TT_VERSION, TT_DATE);
                                               ^
tidy-json.cxx:88:60: error: use of undeclared identifier 'TT_DATE'
    SPRTF("%s version %s, circa %s\n", module, TT_VERSION, TT_DATE);
                                                           ^
2 errors generated.

Do you know what it means? Thanks.

geoffmcl added a commit that referenced this issue Nov 23, 2018
@geoffmcl
Copy link
Owner

@paxperscientiam it would be difficult, but not impossible, to directly use a compiler like that...

I have now added a Build Project section to the README.md which I hope helps... commit
b226ca5

Once you have installed cmake, you should be able to build this project with the following -

$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make

And provided you at least have tidy installed, you should get some of the apps in this suite built...

You have chosen quite a difficult project to cut your C/C++ teeth on ;=))

You should at least be able to build https://github.com/htacg/tidy-html5 tidy, which this suite is based on...

Feel free to ask questions if you are still have trouble...

@paxperscientiam
Copy link
Author

paxperscientiam commented Nov 23, 2018

Hi @geoffmcl . Yeah, I'm sure that I'm in over my head :)

cmake ran just fine; however, I'm running into trouble with make.

I tried pointing to headers and such, but no luck.
Dump:

➤ CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib make
[  9%] Built target utillib
[ 12%] Linking CXX executable sample2
Undefined symbols for architecture x86_64:
  "_TidyLangPosixName", referenced from:
      _tidyPrintWindowsLanguageNames in sample2.c.o
      _main in sample2.c.o
  "_TidyLangWindowsName", referenced from:
      _tidyPrintWindowsLanguageNames in sample2.c.o
      _main in sample2.c.o
  "_getInstalledLanguageList", referenced from:
      _tidyPrintTidyLanguageNames in sample2.c.o
      _main in sample2.c.o
  "_getNextInstalledLanguage", referenced from:
      _tidyPrintTidyLanguageNames in sample2.c.o
      _main in sample2.c.o
  "_getNextWindowsLanguage", referenced from:
      _tidyPrintWindowsLanguageNames in sample2.c.o
      _main in sample2.c.o
  "_getWindowsLanguageList", referenced from:
      _tidyPrintWindowsLanguageNames in sample2.c.o
      _main in sample2.c.o
  "_tidyGetLanguage", referenced from:
      _main in sample2.c.o
  "_tidyLibraryVersion", referenced from:
      _main in sample2.c.o
      _give_help in sample2.c.o
  "_tidyLocalizedString", referenced from:
      _main in sample2.c.o
  "_tidySetEmacsFile", referenced from:
      _main in sample2.c.o
  "_tidySetLanguage", referenced from:
      _main in sample2.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [sample2] Error 1
make[1]: *** [CMakeFiles/sample2.dir/all] Error 2
make: *** [all] Error 2

Thoughts? ty

EDIT: I am running the macport version of tidy. Version is this: HTML Tidy for Apple macOS version 5.6.0

@geoffmcl
Copy link
Owner

@paxperscientiam well this seems to be further along...

The output from the cmake .. ... step should tell where it found tidy, and set up the correct CFLAGS ... you should not have to add this... show me this output...

I am not familiar with the macport... where exactly are tidy.h, libtidys.a, libtidy.so installed... advise...

I searched around for ld: symbol(s) not found for architecture x86_64 and got quite a lot of hits... one good suggestion was to clean up first, especially delete CMakeCache.txt and CMakeFiles dir, etc...

Multiple runs of cmake can keep picking up the previous bad information, and not do a clean search for things again... this is so important I have a cmake-clean script which I run all the time...

#!/bin/sh
#< cmake-clean - 20130702 - 20120612
BN=`basename $0`
echo "$BN: Running cmake-clean 20130702"
TMPFIL="cmake-clean.txt"
TMPDIRS="CMakeFiles"
TMPFILS="cmake_install.cmake Makefile CMakeCache.txt bldlog-1.txt"
# delbu . -n # del *~ files
# deltemp NOPAUSE # del temp* files..

for arg in $TMPDIRS; do
    if [ -d "$arg" ]; then
        echo "$BN: delete directory [$arg]"
        rm -rf $arg
    fi
done

for arg in $TMPFILS; do
    if [ -f "$arg" ]; then
        echo "$BN: delete file [$arg]"
        rm -f $arg
    fi
done

# page of 'operators' from : http://tldp.org/LDP/abs/html/fto.html
if [ -f "$TMPFIL" ]; then
    echo "$BN: Reading and processing input file $TMPFIL"
    while read LINE; do
        if [ -d "$LINE" ]; then
            echo "$BN: delete Directory [$LINE]"
            rm -rf $LINE
        elif [ -f "$LINE" ]; then
            echo "$BN: delete File [$LINE]"
            rm -f $LINE
        elif [ -L "$LINE" ]; then
            echo "$BN: delete Link [$LINE]"
            rm -f $LINE
        #else
	#    if [ ! -z "$LINE" ]; then
        #    	echo "$BN: Not -d, -f, -L! What is this '$LINE'"
	#    fi
        fi
    done < $TMPFIL
fi

echo "$BN: remaining after clean..."
ls -l

# eof

And to see the command passed to the compiler/linker add -DCMAKE_VERBOSE_MAKEFILE=ON... this helps understand what is going wrong... attach this output...

Keep at it... you will get there...

@paxperscientiam
Copy link
Author

paxperscientiam commented Nov 25, 2018

Hi @geoffmcl

Locations of stuff:

/opt/local/include/tidy.h
/opt/local/lib/libtidys.a

I don't see any libtidy.so ... there's a /opt/local/lib/libtidy.dylib, but not sure if that's related.

The problem may come down to this (capturing files from two different builds):

-- +++ Search using paths /usr/local
-- Found TIDY: /usr/lib/libtidy.dylib
-- *** Tidy found inc /opt/local/include lib /usr/lib/libtidy.dylib
-- Found CURL: /usr/lib/libcurl.dylib (found version "7.54.0")
-- *** CURL found inc /usr/include lib /usr/lib/libcurl.dylib
-- cURL version 7.54.0 type SHARED
-- *** Using current Tidy API - no locale test
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ramos/repos/tidy-test/build

...

OK, this was the problem. When I set paths for cmake to ignore, the resultant makefile worked!

This was the command I used:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_IGNORE_PATH="/usr/lib;/usr/local;/usr/shared" ..

I'm guessing PATH was being (partially?) ignored?

Oh, and thanks for the script -- works very nicely!

For posterity, here is the complete output from the above command:

➤ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_IGNORE_PATH="/usr/lib;/usr/local;/usr/shared" ..
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- +++ Search using paths /usr/local
-- Found TIDY: /opt/local/lib/libtidy.dylib
-- *** Tidy found inc /opt/local/include lib /opt/local/lib/libtidy.dylib
-- Found CURL: /opt/local/lib/libcurl.dylib (found version "7.54.0")
-- *** CURL found inc /usr/include lib /opt/local/lib/libcurl.dylib
-- cURL version 7.54.0 type SHARED
-- *** Using current Tidy API - no locale test
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ramos/repos/tidy-test/build

In case you're wondering why I'm digging into this, I'm trying to help make tidy and the emacs library flycheck compatible again.

The build of tidy-json is indeed functional.

EDIT:

So, if I understand correctly, work on tidy-json needs to be completed? Was/is the plan to merge into main?

@geoffmcl
Copy link
Owner

@paxperscientiam glad to hear you seem to have got there... good work... congrats... ;=))

Yes, I should have remembered, the shared library tidy would be called libtidy.dylib in a mac.

It is libtidy.so in unix, and tidy.dll in Windows... one must take care of the changing name across different systems... thanks for the reminder...

Now it is also interesting that it seems tidy is in installed in /opt/local/ in the mac... ok, that's probably a macports decision... no particular problem...

But the first cmake output configuration seems very confused... it mentions both!

-- *** Tidy found inc /opt/local/include lib /usr/lib/libtidy.dylib

Why does it reference /usr/lib/libtidy.dylib? What did it find there? Does such a library, or link, exist there...

Ok, you cleaned that all away, and added an exclude -DCMAKE_IGNORE_PATH="/usr/lib;/usr/local;/usr/shared", so then you get what looks like the correct output...

- *** Tidy found inc /opt/local/include lib /opt/local/lib/libtidy.dylib

Seems a little more to understand here, but no problem, you got it working...

Now as to the functionality of tidy-json... I don't remember... sorry... you will note it did not even make it to the README.md...

Briefly look at the code, I think I was using it to test my ability to write json... but not sure...

I used the tidy node tree, and message outputs, to generate them in json, nothing more... lessons learned... done... finished... there was no other aim for the app...

So there will be no additional work on tidy-json from my perspective...

Do not know how helpful this would be in make tidy and the emacs library flycheck compatible again.... very, very seldom use emacs, and know nothing about flycheck...

Hope this helps...

@paxperscientiam
Copy link
Author

Why does it reference /usr/lib/libtidy.dylib? What did it find there? Does such a library, or link, exist there...

Indeed, there is a symlink that points to /usr/lib/libtidy.A.dylib

It belongs to a very old version of tidy that comes with macos, which is located at /usr/bin/tidy.
This is the version output: HTML Tidy for Mac OS X released on 31 October 2006 - Apple Inc. build 16.1.

2006!

So there will be no additional work on tidy-json from my perspective...

Understood. This may be a good opportunity for me start learning C++ -- of which I am totally ignorant!

I used the tidy node tree, and message outputs, to generate them in json, nothing more.

Is that to say there's an API of sorts that I could study?

Thanks a lot for your help @geoffmcl. It would be cool if I could build on your work. I'll try not to trouble you with frivolous PRs. :D

@Mralfa68
Copy link

Hi @geoffmcl , I'm very new to C, so please bear with me. I'm trying to build tidy-json.cxx; however, I'm running into the following error:

➤ c++ tidy-json.cxx
tidy-json.cxx:88:48: error: use of undeclared identifier 'TT_VERSION'
    SPRTF("%s version %s, circa %s\n", module, TT_VERSION, TT_DATE);
                                               ^
tidy-json.cxx:88:60: error: use of undeclared identifier 'TT_DATE'
    SPRTF("%s version %s, circa %s\n", module, TT_VERSION, TT_DATE);
                                                           ^
2 errors generated.

Do you know what it means? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants