• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Moving from Xcode to Cmake, Photoshop SDK, linking error.

Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hey

 

So, my Xcode project exploded, and no longer want to compile. I've spent 2 weeks trying to fix it, I gave up. So the time has come to move to Cmake! I managed to do the port on windows <YAYYY> but I'm struggling on mac...

I'm stuck on the last part (I think) linking!

I'm using Getter example project as my starter...

Here are my errors :

 

 

ld: warning: ignoring file ../libOutput/resourceBuild/Debug/pluginConfig_PIPL.rcrs, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x00 0x00 0x01 0x00 0x00 0x00 0x04 0x49 0x00 0x00 0x03 0x49 0x00 0x00 0x00 0xEC )
Undefined symbols for architecture x86_64:
  “_PIstrlcat”, referenced from:
      DoIt(PSActionsPlugInMessage*) in Getter.cpp.o
  “PIUGetInfo(unsigned int, unsigned int, void*, void*)“, referenced from:
      DoIt(PSActionsPlugInMessage*) in Getter.cpp.o
      GetApplicationInfo(char*) in GetInfoFromPhotoshop.cpp.o
      GetHistoryInfo(char*) in GetInfoFromPhotoshop.cpp.o
      GetLayerInfo(char*) in GetInfoFromPhotoshop.cpp.o
      GetPathInfo(char*) in GetInfoFromPhotoshop.cpp.o
      GetActionInfo(char*) in GetInfoFromPhotoshop.cpp.o
      GetDocumentInfo(char*) in GetInfoFromPhotoshop.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

 

 

As far as I can tell there 2 errors here.

1. Linking error - undefined symbols

2. rcrs error which I think is there because the app did not link properly in 1st place... so maybe we can ignore this part now...

 

Now given the fact that SDK does NOT actually have any lib/sa/a/dylib/dll/etc in itself... I have NO IDEA how on earth this thing even works on windows. All I know is that the same Cmake does not work on mac. 

 

So skipping the REZ generation for now... my cmake mostly is made out of : 

 

set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE)

include_directories(${PS_SDK_ROOT}/samplecode/common/includes)
include_directories(${PS_SDK_ROOT}/samplecode/common/sources)
include_directories(${PS_SDK_ROOT}/samplecode/common/resources)
#include_directories(${PS_SDK_ROOT}/samplecode/common)
include_directories(${PS_SDK_ROOT}/photoshopapi/photoshop)
include_directories(${PS_SDK_ROOT}/photoshopapi/PICA_SP)
include_directories(${PS_SDK_ROOT}/photoshopapi/resources)
#include_directories(${PS_SDK_ROOT}/photoshopapi)

set(ALL_FILES
        mainPlugin.cpp # this is getter example project
        ${SRC_LOCAL} # this is getter.cpp etc
        ${PS_SRC_EXTRA} # ignore.
        )
add_library(${PROJECT_NAME} SHARED ${ALL_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${ROOT_LIB_OUTPUT}/")
set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_PDB_OUTPUT_DIRECTORY "${ROOT_LIB_OUTPUT}/")
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX .plugin)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}${GLOBAL_OUTPUT_SUFFIX_TYPE})

set_target_properties(${PROJECT_NAME} PROPERTIES
        BUNDLE 1
        BUNDLE_EXTENSION plugin
        XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin  #sets the extension to .plugin
        XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
        XCODE_ATTRIBUTE_INFOPLIST_FILE ${ROOT_SRC}/pipl/Info.plist
        MACOSX_BUNDLE_INFO_PLIST ${ROOT_SRC}/pipl/Info.plist
        )
set_source_files_properties(
        ${PIPL_OUTPUT}
)
    set(ADDITIONAL_LIBRARY_DEPENDENCIES
            #"-framework Carbon"
            #"-framework CoreServices"
            stdc++
            ${PIPL_OUTPUT}
            )
    target_link_libraries(${PROJECT_NAME} "${ADDITIONAL_LIBRARY_DEPENDENCIES}")

 

 

Now here is where I hit a wall... I've no idea how to fix that linking error 😄 

I've gone over xcode project TOP-TO-BOTTOM 50x. I even read the xcode project as text file and went over each entry. 

I disabled all flags in xcode project, it builds and links. So I don't really need any custom flags in cmake - not like in windows (oh god so many flags there!). So As far as I can tell, I have the same stuff set/configured in cmake. But still errors...sigh.

 

In any case, I'm stuck. Can any1 help out?

Regards

Dariusz

TOPICS
macOS , SDK

Views

564

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 24, 2022 Jun 24, 2022

Hey

 

Sorry for late reply!

Been quite hectic here last week... in any case.. the secret sauuceeeee uuuuUUUuuUUUuuu:

 

1. Linking issues. 

Just stuff 

#include <PIUSuites.cpp>

 In your main.cpp file (or whichever main.cpp u use that has plugin function) at the top and that will fix the linking issue.

 

2. Resource building...
The magical code ended up being : 

    set(macSDKPathRez
            -i ${Sdk_Path}/common/resources
            -i ${Sdk_Path}/common/includes
            -i ${Sdk_Path}/common/source
...

Votes

Translate

Translate
Adobe
Adobe Employee ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

I only know one thing about PiPL files, and it's all in this article: https://medium.com/adobetech/an-illustrator-25-1-update-for-plugin-developers-31aa4baaeecc?source=fr...

 

You might find something like the macOS deprecation of some PiPL file means you have to update something in order to complie.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hey @erinferinferinf Thanks for the ping!

Interesting read, will definitely help if it's the same as PS. I got it "working" with rez, but can't hurt to do it illustrator way too ! 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

You should post how you solved this 😁 (because then it will be Googlable later for yourself and others)!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 24, 2022 Jun 24, 2022

Copy link to clipboard

Copied

Hey

 

Sorry for late reply!

Been quite hectic here last week... in any case.. the secret sauuceeeee uuuuUUUuuUUUuuu:

 

1. Linking issues. 

Just stuff 

#include <PIUSuites.cpp>

 In your main.cpp file (or whichever main.cpp u use that has plugin function) at the top and that will fix the linking issue.

 

2. Resource building...
The magical code ended up being : 

    set(macSDKPathRez
            -i ${Sdk_Path}/common/resources
            -i ${Sdk_Path}/common/includes
            -i ${Sdk_Path}/common/sources
            -i ${Sdk_Path}/photoshop
            -i ${Sdk_Path}/pica_sp
            -i ${Sdk_Path}/resources)
    add_custom_target(PiPL ALL
            COMMENT "Build PiPL..."
            SOURCES ${pipFilePath}
            BYPRODUCTS ${buildTempPath}/${pluginName}.rsrc
            COMMAND [ ! -f "${buildTempPath}" ] && mkdir -p "${buildTempPath}"
            COMMAND Rez -o ${buildTempPath}/${pluginName}.rsrc
            -d SystemSevenOrLater=1 -useDF -arch x86_64 -script Roman ${PiPL_DEFINE}
            -isysroot `xcrun --sdk macosx --show-sdk-path`
            ${macSDKPathRez}
            ${Sdk_Path}/common/includes/MachOMacrezXcode.h
            ${CMAKE_CURRENT_SOURCE_DIR}/${pipFilePath}
            COMMAND echo ${Plugin_Name}.rsrc done!
            )

 

And the way to get it... start xcode > load up photoshop SDK plugin example > build > go to build logs... and then you will see log & action that happen on each step... when you move your mouse to right, there is little icon with 3 lines... click on it, it opens up and show you the command! 😄 Copy paste run!

Hope this helps any future c++ poor soul that decided to discover the wonders of photoshop c++ development...................

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

Hey Dariusz,

 

I'm struggling with porting my Xcode project to cmake as well... I managed to compile & link it, but it won't load in Photoshop... It shows an entry in Filters, but when I try to open the plugin it shows "Could not complete the XXX command because the file was not found". Any ideas? I checked everything so many times... even compared the files with HEX editor... and can't find what the issue is.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

Hey
Try this one
https://sonictk.github.io/ps_cpp_recipes/

Else post hello world source/cmake/etc.
Hard to help without I'm afraid.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

LATEST

Thanks for the link - really great resource! 

Regarding my problem - foiund the solution. It seems my other settings set all the symbols to be hidden and I had to explicitly set the entry point with this:

 __attribute__((visibility("default")))

After that the plugin loaded properly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines